Back to

Storing data in mysql database

I want to store my data from firmware directly in my mysql database (not via restful api). Dived into the code. It is poorly documented. What’s the best approach here? Anyone done this already?

Hello Marc,

We are currently working on documenting properly our current backend to release it publicly.

The Smart Citizen Kit is publishing by default the data as a PUT Http request, the sensor data is encoded as JSON.

Here you can see how a kit’s request will look like.

curl -X PUT -H 'Host:' -H 'User-Agent: SmartCitizen' -H 'X-SmartCitizenMacADDR: 00:00:00:00:00:00' -H 'X-SmartCitizenVersion: 1.1-0.8.5-A' -H 'X-SmartCitizenData: [{"temp":"29090.6","hum":"6815.74","light":"30000","bat":"786","panel":"0","co":"112500","no2":"200000","noise":"2","nets":"10","timestamp":"2013-10-28 1:34:26"}]'

Data for the temperature, humidity and noise is sent it in raw and then calibrated in our platform.

Here are the different paths you can take in order to built your own backend.

  • Create a fork of the the Smart Citizen Kit firmware in order to send the data as your custom backend expect it.
  • Create your own custom backend. We can share all the different modules of our backend in order for you to receive data as on the curl example above, calibrate it and store it.
  • Keep using our backend but request our public API and then fill your local Mysql with it.

Please, let me know what option you will like the most and I can share with you our documentation.


Hello Guillem.

Added some new code to firmware version 0.8.6. Compiling went ok. During upload something went wrong. (yes i selected the right board: lilypad usb). Now usb isn’t working anymore. Trying to burn new bootloader with arduino uno. Please specify pin layout of ICSP.


Hi Marc! The ICSP pin layout is the same as in Arduino. Best. :slight_smile:



Just to be sure:
pin 1 (MISO) is near Wifly card?
burning bootloader is done with 3,3 V not 5 V?


What programmer do you use? Yes, is near Wifly card. VCC is 3.3v.


I tried using arduino uno as programmer. Having trouble burning the bootloader. Keep getting the famous error “avrdude: Yikes! Invalid device signature.”

The relevant part of the boards.txt file is: Arduino USB

The relevant part of the programmers.txt file is: as ISP

The relevant part of the avrdude.conf file is:




id = “m32u4”;
desc = “ATmega32U4”;
signature = 0x1e 0x95 0x87;
has_jtag = yes;

stk500_devcode = 0xB2;

avr910_devcode = 0x43;

Are these settings correct?

Anyone succeeded burning the bootloader?


We program the boards from the Arduino IDE, and never given us problems, we use the AVRISP mkII programmer.


Tried using arduino uno as programmer for the board. It’s not working. Burning a bootloader onto another arduino uno works. Ordered the AVRISP mkII programmer. Keep you informed.


Hi, I’ve tried to program with Arduino Duemilave and working properly, I send you a screenshot with the wiring.

@marcvreeburg after making similar code changes to my kit I also lost the USB totally. I was able to revive the board by pressing the reset button twice in rapid succession. See .

Hopefully this helps.

@marcvreeburg; Apparently we share the same ambition. Did you already made some progress? Or does anyone know about the documentation status.

I would like to send the information from the sck directly to a OGC SOS ( In order to do this, I need to transform the PUT-request into a POST-request.

Like the following Python example:
webservice = httplib.HTTP(“XXX.XXX.XX.X:8080”)
webservice.putrequest(“POST”, “/SOS/json”)
webservice.putheader(“Host”, “XXX.XXX.XX.X:8080”)
webservice.putheader(“User-Agent”, “SCK post”)
webservice.putheader(“Content-type”, “application/json; charset=“UTF-8"”)
webservice.putheader(“Content-length”, “%d” % len(SoapMessage))
webservice.putheader(“SOAPAction”, “””")

Looking forward to hear any suggestions.