RPi 3 - Sending back boolean value to Losant API

I have been having some trouble following the tutorials present on the website. Basically what I would like to do is: after the RPi 3 checks if the sensor value matches the correct number, it should send either a 0 if there’s no match or 1 if there’s a match, back to the Losant API. How can I retrieve this value and what http request would I use in my web app? I would really appreciate an example or some directions on how to go about this. Thank you so much in advance!

What is the sensor and how are you reading the data off of it now? If it’s a Python script, you could use our Python SDK to send the data to Losant given the condition you describe. We also have a JavaScript SDK in case you’re reading the data in a Node.js application.

As for reading the data, there are a number of ways you could do that:

If you can provide more specifics about your particular use case, I may be of more help.

Thank you for your prompt reply! So for the application I have an NFC reader module connected to RPi 3, and I want it to just check the NFC cards and check whether the values match some pre defined values. If the UID matches, the script outputs a 1 but if it doesn’t then it outputs a 0. So far I have implemented the workflows in Losant to control the GPIO pins on the RPi from a web application on a smartphone using an HTTP GET request. Now I just want the web application to retrieve whether the RPi’s NFC reader outputs a 0 or 1 when scanning an NFC card. What do you think is the best direction to go with this?

If I’m understanding your setup correctly, then I would suggest you register the RPi as a device in your Losant application, and give it a single attribute (call it “nfcReading”) of the type Number (or boolean if you prefer).

Then, every time your script on the Pi outputs a 1 or a 0, send that state to Losant through our REST API (or one of the clients I mentioned previously).

Finally, when you wish to retrieve that value in your web application, you can retrieve it not from the Pi itself, but from the Losant platform – again, using our API directly or through one of our client libraries.

Let me know if this helps!

1 Like