Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: Send Data from Sensor with SX1272 Module URGENT !!!
PostPosted: Sat Mar 11, 2017 11:37 pm 

Joined: Sat Mar 11, 2017 11:35 pm
Posts: 1
Hi,

I need send data from sensors using the SX1272 Module... the codes is works if I send messages char type... but when I configure the program to send the data received from a sensor only receive a square...



Is there an error that the receiver does not show the real value ???

the code for the transmitter is the following:


// Include the SX1272 and SPI library:
#include "SX1272.h"
#include <SPI.h>

int e;
const int xpin = A8;
const int ypin = A9;
const int zpin = A10;
int rawx;
int rawy;
int rawz;
int scaledx;
int scaledy;
int scaledz;
//char message1;

void setup()
{

Serial.begin(9600);
Serial.println(F("SX1272 module and Arduino: send packets without ACK"));
e = sx1272.ON(); //Power ON
Serial.print(F("Setting power ON: state "));
Serial.println(e, DEC);
e = sx1272.setMode(4); // Transmission
Serial.print(F("Setting Mode: state "));
Serial.println(e, DEC);
e = sx1272.setHeaderON(); //Header
Serial.print(F("Setting Header ON: state "));
Serial.println(e, DEC);
e = sx1272.setChannel(CH_10_868);// Channel
Serial.print(F("Setting Channel: state "));
Serial.println(e, DEC);
e = sx1272.setCRC_ON();//CRC
Serial.print(F("Setting CRC ON: state "));
Serial.println(e, DEC);
e = sx1272.setPower('H');//Output Power
Serial.print(F("Setting Power: state "));
Serial.println(e, DEC);
e = sx1272.setNodeAddress(3);//Node Address and print the result
Serial.print(F("Setting node address: state "));
Serial.println(e, DEC);
Serial.println(F("SX1272 successfully configured"));
Serial.println();
}

void loop(void)
{


rawx=analogRead (xpin);
rawy=analogRead (ypin);
rawz=analogRead (zpin);
scaledx=((rawx-330)/(3.369));
scaledy=((rawy-329.5)/(-3.5168));
scaledz=((rawz-340)/(6.422));


//Serial.print(scaledx);Serial.print("\t"); //Acceleration X Axis
//Serial.print(scaledy);Serial.print("\t"); //Acceleration Y Axis
//Serial.print(scaledz);Serial.print("\t\t"); //Acceleration Z Axis
//Serial.print("\n");

delay(1000);


// Send message1 and print the result


e = sx1272.sendPacketTimeout(8,scaledx);
Serial.println(scaledx);
Serial.print(F("Packet sent, state1 "));
Serial.println(e, DEC);


delay (1000);
}


and for the receiver:


// Include the SX1272 and SPI library:
#include "SX1272.h"
#include <SPI.h>

int e;
char my_packet[12];

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);

// Print a start message
Serial.println(F("SX1272 module and Arduino: receive packets without ACK"));

// Power ON the module
e = sx1272.ON();
Serial.print(F("Setting power ON: state "));
Serial.println(e, DEC);

// Set transmission mode and print the result
e = sx1272.setMode(4);
Serial.print(F("Setting Mode: state "));
Serial.println(e, DEC);

// Set header
e = sx1272.setHeaderON();
Serial.print(F("Setting Header ON: state "));
Serial.println(e, DEC);

// Select frequency channel
e = sx1272.setChannel(CH_10_868);
Serial.print(F("Setting Channel: state "));
Serial.println(e, DEC);

// Set CRC
e = sx1272.setCRC_ON();
Serial.print(F("Setting CRC ON: state "));
Serial.println(e, DEC);

// Select output power (Max, High or Low)
e = sx1272.setPower('H');
Serial.print(F("Setting Power: state "));
Serial.println(e, DEC);

// Set the node address and print the result
e = sx1272.setNodeAddress(8);
Serial.print(F("Setting node address: state "));
Serial.println(e, DEC);

// Print a success message
Serial.println(F("SX1272 successfully configured"));
Serial.println();
}

void loop(void)
{
// Receive message
e = sx1272.receivePacketTimeout(10000);
if ( e == 0 )
{
Serial.print(F("Receive packet, state "));
Serial.println(e, DEC);

for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
{
my_packet = (char)sx1272.packet_received.data;
}
Serial.print(F("Message: "));
Serial.println(my_packet);
}
else {
Serial.print(F("Receive packet, state "));
Serial.println(e, DEC);
}
}


Top
 Profile  
 
 Post subject: Re: Send Data from Sensor with SX1272 Module URGENT !!!
PostPosted: Mon Mar 13, 2017 3:54 pm 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi amvlazqzloz13,

Can you show us the serial monitor?

Which sensor are you using?

Thanks.

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.