Arduino code to send voltage, current and power to the things network with uplink

Please please please can you confirm:

as at this stage, we don’t even know if the device is actually transmitting.

And then please please please confirm that you are seeing the transmitted data in the web console - as that will confirm that all the transmission settings are correct.

1 Like

I am seeing my transmitted data both on the serial monitor and on the web interface,
when i send downlink i also see it scheduled. but it will not get to the node…serial monitor

Only in the gateway’s Traffic page, or also in the application/device’s Data page? Only when you see it in the Data page in TTN Console, you know for sure that the device’s configuration matches the secrets that TTN knows, and that TTN has accepted the value of your uplink counter. (The latter check may be disabled, for testing.)

Here, it’s the other way around: are you only seeing it in the application/device’s Data page, or also in the gateway’s Traffic page? (Or even in the gateway’s log files?) Screenshots will help confirm all this.

Aside:

Beware that, after testing, you’re only allowed to do this at most 10 times per 24 hours.

Morning @cherechi, I think we are really close to solving this.

As Arjan said, just for peace of mind because the downlink will never work if the credentials aren’t correct, can you confirm that you are seeing the uplink on the Device’s Data tab - note, this only shows real time, so you won’t see anything until there is an uplink whilst the page is open.

I use almost exactly the same code base for Arduino 328P + RFM95 setups so I am quite familiar with the issues - it took me a while to get things going but once I did, it works nicely. Whilst you check the console, I’ll get one out so I can dip in to the code myself.

Thanks alot for your concern, I do get the uplinks on the data tab, also i do see the downlinks on the gateway log as shown in the image below as it is sent at 869.525MHz but it never arrives at the node to turn on the LED. But this morning, I tried sending a downlink, my node recieved it and the LED was turned on. now i cannot turn it off anymore as the dowlink will not get to the node againDOWNLINK serial monitor

Woo hoo!

So we know it can work, we just need to make it work more reliably, so I’d look at Arjan’s comment about the timing tuning:

But also, as I should have mentioned sooner, you should limit downlinks as they render the gateway totally deaf whilst transmitting. So what is the LED for? Can it operate locally?

let me ask this question, If I have a server such as chirpstack installed locally on my gateway with the need to transmit to the things network, will i be able to send more frequent downlinks. this downlink is supposed to be sent for control purposes. such as alarm or control a servo…

If you have your own network & application server then you will only be limited by your local laws / regulations for transmissions as you won’t be using TTN.

However if you have your own server, then you won’t be on TTN so you will need to have a reliable server & internet connection.

Thank you so much for this reply, you have been very helpful. so back to the LED. since i can only send 10 downlinks in 24 hours, i just want to confirm that my downlink can turn on and off the LEDS. this will not be up to 10 dowlinks.

Not sure I fully understand your meaning.

TTN fair use policy is for 10 downlinks per 24 hour period per device.

What you send and what it does is entirely up to you - LEDs, pump, MP3 player, siren and so much more.

But you should consider the consequences that the device happens not to transmit & therefore receive on the schedule you expect or does, but doesn’t get the downlink. So nuclear reactors etc aren’t a good idea.

1 Like

@cherechi I find this discussion very helpful, one point of interest - AnalogRead by default returns a float and in your example you’re using uint32_t as the return value from AnalogRead - that’s 4 bytes for float compared to 2 for uint32_t

Isn’t there an issue of accuracy meaning being cable to capture the entire range of the ADC?

Also if I may share - I have found that doing the match is much easier with a decoder function rather than do it at firmware level. TTN has awesome decoder capability. My example below does the same thing on a 3.3v board:

function Decoder(bytes, port) { 
var decoded = {};

bytes[2];
decoded.battery_voltage = 
((bytes[0]*256+bytes[1])*2)*0.0032258064516129;


  return decoded; 
}

Perhaps not: