Hi,
I want to send the readings from the kit directly to my own platform.
I’ve already used the APIs from SCK platform, and I’m currently reading the information my Kit has uploded to SCK platform, sending it to my platform, and working with it.
Now I want to do it the other way, that is, read directly into my platform from MQTT sent by the kit, and then send the information to the SCK platform or other platform.
This is the information of the versions I’m using:
version
Hardware Version: 2.1 | |||
---|---|---|---|
SAM Hardware ID: 111BF6AD50515157382E3120FF0F2204 | |||
SAM version: 0.9.8-e283e58 | |||
SAM build date: 2021-09-13T14:17:43Z | |||
ESP MAC address: B6:E6:2D:65:AA:52 | |||
ESP version: 0.9.8-e283e58 | |||
ESP build date: 2021-09-13T14:18:25Z |
I’m working on Windows.
I can think of two ways of doing this:
-
Redirecting the traffic from smartcitizen.me to my server using some DNS redirection
But this is something I might be able to do at home, and a regular citizen user will probably not be able to do. So this will work only for the kits I have in my network. So I won’t go this way. -
Changing the MQTT server configuration in the Kit.
I would rather prefer not having to burn the whole firmware for a few changes, because I’m no expert in programming, and I’m a bit afraid of having to deal with the whole firmware upgrading thing on my own right now. Unless it is the only way, of course.
So far I’ve done the following:
Using Arduino IDE
changed from the original configuration: mqttsrv -host mqtt.smartcitizen.me -port 1883
to my local broker: mqttsrv -host 192.168.0.108 -port 1883
As my server requires some authentication, and the only authentication the Kit is sending is the Token generated at the onboarding process, I used it as the authentication for my platform.
After some configuration I got the following:
SCK > mqttsrv
Mqtt Host: 192.168.0.108
Mqtt Port: 1883
SCK > config
Mode: network
Publish interval (s): 60
Reading interval (s): 30
Wifi credentials: mylocalnet - password
Token: sckToken
Mac address: themacaddress
When the kit reads data it shows the following:
SCK >
-----------
2021-11-03T00:28:12Z
Temperature: 22.04 C
Humidity: 79.99 %
Battery: 99 %
Light: 89 Lux
Noise dBA: 42.52 dBA
Barometric pressure: 100.97 kPa
VOC Gas CCS811: null ppb
eCO2 Gas CCS811: null ppm
-----------
(2021-11-03T00:28:12Z) Readings saved to flash memory.
Recent user interaction, it's time to publish
Connecting to Wifi...
ESP on...
ESP finished booting
Synced config with ESP!!
Connecting to Wifi...
Connected to wifi!!
(2021-11-03T00:28:12Z) Sent readings to platform.
{t:2021-11-03T00:28:12Z,10:99,14:89,55:22.04,56:79.99,53:42.52,58:100.97}
Network publish OK!! (6 readings)
ESP off...
So, apparently, it is publishing the readings.
The problem I have right now is that I’m not receiving anything on my platform. And I don’t know how to debug or trace this to get a hint of what could be happening.
To test the platform is working fine I’ve done the following: (from the command line)
mosquitto_pub -d -q 1 -h "192.168.0.108" -t "v0/devices" -i sckToken -m {70:29}
and it works perfectly.
I’ve used a number in the key, because I’ve seen the kit has the sensors encoded and when it sends the key/value pair it just sends the sensor number and not a string key.
Also I have created a topic in the server similar to the one SMC publishes to, as I couldn’t find a way to change the topic from the shell.
So, in summary:
- I think I’ve configured the Kit to point to my server, and at least the Kit believes it is sending the information there .
- I’ve configured the server to receive the readings, and tested it with another MQTT client, and it works fine.
I don’t know where to go from here, so pleeease heeeelp!! I will really appreciate it !!!
Thank you very much !!!
Warm regards
Ricardo