My First Device

I just got my ST STM32. I followed the tutorial and successfully got the TransmitPacket Sketch working. I have the packets going to an HTTP channel at RequestBin. In the console, I can see the HotSpots in my neighborhood that are hearing me. So cool!

I now need some pointers to take the next step.

I’m going to be doing some traveling and I’d like to take my device with me to have it track where I go. My thought was to simply record the location of the hotspots involved in routing my packets.

How would I go about that? Any pointers are greatly appreciated.

1 Like

Also, I’m having some trouble understanding the format of the payload field. I can’t find any documentation for this. It seems that the call to LongFi.send() creates a JSON package with a bunch of fields, including “payload”, but I can’t decipher what I am seeing at RequestBin.

1 Like

Nice work! We’ll whip up a sample JSON payload / request later today.

Aside from that, what else do the docs need to get you and other new users moving quickly?

Thanks. I would love to see an example of getting data back to the device. I think RequestBin supports this.

I’m having some trouble understanding the format of the payload field.

The JSON field payload should match precisely the data you feed LongFi.send. It is base64 encoded so whatever language you are parsing the Http post with should have some native function to parse it.

That’s what I needed. Thanks.

I need just a little more help on this. I am now getting the POST data in my wsgi/Apache python app via my Helium channel. The data looks like:

{'oui': 1, 'payload': 'AQIDBAUGBwg=', 'timestamp': 1574372717, 'fingerprint': 178398717, 'rssi': -46.0, 'spreading': 'SF10', 'sequence': 20, 'snr': 9.25, 'gateway': 'breezy cherry chipmunk', 'device_id': 22}

The payload hold the data that was written on my device as:

uint8_t data[8] = {1, 2, 3, 4, 5, 6, 7, 8};
LongFi.send(data, sizeof(data));

I don’t know how to get that array back from the Base 64 string ‘AQIDBAUGBwg=’

How would I send and receive a string?

Hi @dellisny,

You just need to decode the base64 encoded bytes.

Try this:

import base64
encodedString = ‘AQIDBAUGBwg=’
base64.b64decode(encodedString)

Reference: https://docs.python.org/3.7/library/base64.html

-Kent

You have provide an example for python.

Is this a good example in JavaScript in the Chrome developer tools window?

console.log(atob(“fDU6IGhlbGxvfAA=”))
VM181:1 |5: hello|

I am just starting to use JavaScript and node.js. Is there any simpler vehicle I could use besides Chrome developer tools window?

Now I am attempting to add an Adafruit Ultimate GPS to my board so it can report position. I got the GPS board to work when attached to my Arduino Uno. But, that code used SoftwareSerial. SoftwareSerial does not work (or compile) for the STM32 board, because, I think the STM32 has plenty of real serial ports (UART?). But, I can’t figure out what pins map to the these ports. I’m trying to attach the GPS board to Serial2. Where are the Tx/Rx pins for that? I’m stuck.

@dellisny
Are you using this shield? https://www.adafruit.com/product/1272

You can use the SoftwareSerial toggle switch on the GPS shield. You need to jumper the TX pin from the Shield to the PA9 or PA10 USART1_RX pin on the Discovery board. The shield’s TX pin aligns with the D7/PA8 pin on the Discovery board, which you cannot use for this application, so make sure that is not connected.

Hope this helps!

Jeff,

Thank you for your answer. I’m new to this, so please bear with me. The shield I am using is this: https://www.adafruit.com/product/746

As I said, I was able to get this shield to work with my Arduino Uno. To make it work, I connected the shield to 3V and GND and to inputs 7 & 8. I used the following code to initialize the SoftwareSerial connection:

SoftwareSerial mySerial(8, 7);

Adafruit_GPS GPS(&mySerial);

This setup works and reports GPS data across the “real” serial line which is connected to the Arduino tool’s console.

When I try to move this code over to the Discovery board I have a bunch of problems. The Discover board is this: https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html

When I compile the code for this board in the Arduino tool, it complains:

GPS_SoftwareSerial_EchoTest:16:27: error: no matching function for call to ‘Adafruit_GPS::Adafruit_GPS(SoftwareSerial*)’

Adafruit_GPS GPS(&mySerial);

                       ^

In file included from /Users/dellis/Dropbox/Opus/Code/Helium/GPS_SoftwareSerial_EchoTest/GPS_SoftwareSerial_EchoTest.ino:13:

/Users/dellis/Documents/Arduino/libraries/Adafruit_GPS_Library/Adafruit_GPS.h:114:3: note: candidate: ‘Adafruit_GPS::Adafruit_GPS(TwoWire*)’

Adafruit_GPS(TwoWire *theWire); // Constructor when using I2C

I interpret this to mean that the SoftwareSerial library isn’t set up for this board. My guess, maybe wrong, is that this is because the board has plenty of actual serial interfaces to use. But, maybe I just have my build environment incorrectly configured.

So, I change my code to:

Adafruit_GPS GPS(&Serial2);

This compiles fine. But, I don’t know what Serial2 is on the board. How do I find a mapping of the pins on the ST32 board?

Thank you for any clarifications.

@dellisny

Let me take a look at that breakout board. We’ve been using the the I linked because it slots in nicely with the Arduino Pins on the Discovery board.

Can you try using HardwareSerial instead? We can define it like so:

   HardwareSerial Serial1(PA_10, PA_9);
   #define GPSSerial Serial1
   Adafruit_GPS GPS(&GPSSerial);

PA9 and PA10 are the USART1_RX pins on the Discovery board.

Let me know if that helps!

Discovery Datasheet

OK. Now I broke something new! I was able to modify my code as you suggest. But, when I went to test it, I got:

Arduino: 1.8.10 (Mac OS X), Board: “Discovery, Discovery L072CZ-LRWAN1, Mass Storage, Enabled (generic ‘Serial’), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)”

Sketch uses 47368 bytes (24%) of program storage space. Maximum is 196608 bytes.

Global variables use 2548 bytes (12%) of dynamic memory, leaving 17932 bytes for local variables. Maximum is 20480 bytes.

An error occurred while uploading the sketch

"DIS_L072Z not found. Please ensure the device is correctly connected

This report would have more information with

“Show verbose output during compilation”

option enabled in File -> Preferences.

Basically, it looks like I have lost my serial connection to the Discovery board. I’m on a Mac. Can you suggest how I can correct this?