Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
N

nrf24_is_hard

@nrf24_is_hard
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to make sense of Struct data received from Arduino in RPi via NRF24?
    N nrf24_is_hard

    Hi guys,

    I know that for a simple transmission e.g. humidity and temperature, the Arduino can simply fit these into a float array and send it to the RPi.

    The RPi can then execute the following code snippet to get the value:

    DataBytes=8
    receivedMessage=bytearray(DataBytes)
    radio.read(receivedMessage,radio.getDynamicPayloadSize())
    data = struct.unpack('ff',receivedMessage)
    humidity=data[0]
    temperature=data[1]
    

    Arduino snippet:

    struct values{
    char name[15];
    float temp;
    float humi;
    float light;
    float soilMoist;
    float soilTemp;
    float gasSensor;
    float pirSensor;
    };
    struct values DataToSend;
    DataToSend.temp=dht.ReadTemperature();
    //continue storing data in DataToSend
    radio.write(&DataToSend,sizeof(DataToSend))
    

    My question is now, how would I send this struct from the Arduino to the RPi with a similar method like the float array?

    General Discussion arduino raspberry pi rf24

  • How to make sense of received Struct from Arduino via NRF24?
    N nrf24_is_hard

    Hi guys,

    Currently I have been at this for days now, and I just don't know how to decode the struct value upon receiving the struct data from my Arduino. I am using Python on the RPi side, both are fitted with the same NRF24L01 and I am using RF24 Library https://github.com/matmany/lib_nrf24 which is forked from BLavery.

    So my code on the Arduino side is relatively standard, the Arduino transmits a struct data of sensorName[15], Air temperature, Air Humidity, Light sensor, soil Moisture, soil Temperature, gas Sensor and motion Sensor to a defined pipe. Apart from sensorName, these are all declared as Integers as I will convert it to float in RPi to shorten the size of the struct, thus the struct size is 31, just 1 byte away from the maximum.

    Upon running my code at the RPi, I get all sorts of bytes values and I want to convert it to their actual values, which is integer->float.

    RPi code is just something like

    receivedMessage=[]
    radio.read(receivedMessage,radio.getDynamicPayloadSize())
    print(receivedMessage)
    
    OUTPUT:
    different kinds of values
    [0,2,3,195,0,0,0,etc.]
    

    With a previous small side thing I did a few months ago, I only had to transmit temperature and humidity in a float array, and I did it like this, which works!

    DataBytes = 8
    receivedMessage=bytearray(DataBytes)
    radio.read(receivedMessage,radio.getDynamicPayloadSize())
    data = struct.unpack('ff', receivedMessage)
    humidity=data[0]
    temp=data[1]
    
    

    So my question is, how would I do the same in the case of receiving struct?

    General Discussion
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular