Back to Smartcitizen.me

Custom backend

Hello,

I’m currently working on the “SmartCitizen” Arduino board. i want to setup a custom backend. I used the same example as referred in the link

https://docs.smartcitizen.me/#/start/how-to-store-data-in-your-own-database

and cloned the git repository for the example https://github.com/fablabbcn/Smart-Citizen-Kit

The curl command works for me, but when I try to send data using the board, it doesn’t work.

For your information,

  1. The board connects to the Wifii

  2. I can see the various sensor values on the serial terminal.

  3. I changed the WEB[] to

// Basic Server Posts to the SmartCitizen Platform - EndPoint: http://data.smartcitizen.me/add
static char* WEB[8]={
“127.0.0.1”,
“PUT /add.php HTTP/1.1
”,
"Host: 127.0.0.1
",
"User-Agent: SmartCitizen
",
"X-SmartCitizenMacADDR: ",
"X-SmartCitizenApiKey: ",
"X-SmartCitizenVersion: ",
"X-SmartCitizenData: "};

Can you please help me out with this.

Hi @disssid,

It’s really nice you are trying to workout your own server.

Looking quickly at your example the only issue I see is you are using the wrong IP in your kit firmware.

Curl on 127.0.0.1 works because 127.0.0.1 means the loop back IP of your computer something as saying send this internally. Since your curl and your PHP server run on the same computer that is fine.

However when you want your kit to publish since your kit is a separate device on the network you will need to point to the kit to your local or public address. This means that if your kit and computer are on the same local network then you can point the kit to the computer local address. This might look as: 192.168.1.20 or 10.0.0.1, etc.

This means the firmware will look something as:

static char* WEB[8]={ "192.168.1.20", "PUT /add.php HTTP/1.1\ ", "Host: 192.168.1.20 \ ", "User-Agent: SmartCitizen \ ", "X-SmartCitizenMacADDR: ", "X-SmartCitizenApiKey: ", "X-SmartCitizenVersion: ", "X-SmartCitizenData: "};

(“Host:” is not important if you are not running virtual hosts)

Hope this helps!

Keep us posted,

Guillem