Test LORA NODE with Library SX1272, initially created by C.Pham, University of Pau, France for Arduino. Suitable for MBED / NUCLEO / STM32

Dependencies:   SX1272 mbed

This project is an adaptation of C.Pham project, university of Pau, France. Initially developed for Arduino, the library sx1272 and the test program was focused on NUCLEO STM32 by C.Dupaty, high school Fourcade 13120 Gardanne.

Tested on NUCLEO L073 with

- SX1272MB2xAS SHIELD

/media/uploads/cdupaty/picture3.png.200x200_q85.png

- DRAGINO SHIELD V95 WITH GPS http://wiki.dragino.com/index.php?title=Lora/GPS_Shield For DRAGINO move LORA_CLK LORA_DI LORA_DO straps to the right (arduino 11 12 13)

/media/uploads/cdupaty/lora_gps_shield_1.jpg

ALL CONFIGURATIONS FOR ARDUINO HAVE BEEN REMOVED WORK ONLY IN EUROPE

please visit http://cpham.perso.univ-pau.fr/LORA/LoRaDevices.html for original version for ARDUINO

Revision:
1:9f961d34dd8d
Parent:
0:9859cc8476f2
Child:
2:4eef0eca4d26
--- a/main.cpp	Sun Nov 05 14:32:09 2017 +0000
+++ b/main.cpp	Sun Nov 05 17:02:22 2017 +0000
@@ -19,10 +19,14 @@
  *****************************************************************************
  * last update: Sep. 29th, 2017 by C. Pham
  * last update: oct 30th , 2017 by C.Dupaty
+ * ADAPTATION FOR NUCLEO STM32, TESTED ON NUCLEO-L073RZ
+ * ALL CONFIGURATIONS FOR ARDUINO HAVE BEEN REMOVED
+ * WORK ONLY IN EUROPE
+ * please visit http://cpham.perso.univ-pau.fr/LORA/LoRaDevices.html
+ * for ARDUINO version
  */
 #include "mbed.h"
-
-#include <SPI.h> 
+ 
 // Include the SX1272
 #include "SX1272.h"
 
@@ -112,9 +116,9 @@
 
 ///////////////////////////////////////////////////////////////////
 // CHANGE HERE THE READ PIN AND THE POWER PIN FOR THE TEMP. SENSOR
-#define TEMP_PIN_READ  PA_0
+#define TEMP_PIN_READ  PA_4
 // use digital 9 to power the temperature sensor if needed
-#define TEMP_PIN_POWER PA_1
+#define TEMP_PIN_POWER PB_0
 ///////////////////////////////////////////////////////////////////
 
 ///////////////////////////////////////////////////////////////////
@@ -155,7 +159,7 @@
 #define NB_RETRIES 2
 #endif
 
-#if defined ARDUINO_AVR_PRO || defined ARDUINO_AVR_MINI || defined ARDUINO_SAM_DUE || defined __MK20DX256__  || defined __MKL26Z64__ || defined __MK64FX512__ || defined __MK66FX1M0__ || defined __SAMD21G18A__
+#if defined ARDUINO_AVR_PRO || defined ARDUINO_AVR_MINI || defined ARDUINO_SAM_DUE || defined __MK20DX256__  || defined __MKL26Z64__ || defined __MK64FX512__ || defined __MK66FX1M0__ || defined __SAMD21G18A__ || TARGET_NUCLEO_L073RZ
   // if you have a Pro Mini running at 5V, then change here
   // these boards work in 3.3V
   // Nexus board from Ideetron is a Mini
@@ -165,7 +169,7 @@
   // __MKL26Z64__ is for TeensyLC
   // __SAMD21G18A__ is for Zero/M0 and FeatherM0 (Cortex-M0)
   #define TEMP_SCALE  3300.0
-#else // ARDUINO_AVR_NANO || defined ARDUINO_AVR_UNO || defined ARDUINO_AVR_MEGA2560 
+#else // ARDUINO_AVR_NANO || defined ARDUINO_AVR_UNO || defined ARDUINO_AVR_MEGA2560 || 
   // also for all other boards, so change here if required.
   #define TEMP_SCALE  5000.0
 #endif
@@ -216,7 +220,6 @@
 #endif
 
 // ajoute par C.Dupaty
-//Serial pcmain(USBTX, USBRX); // tx, rx
 DigitalOut temp_pin_power(TEMP_PIN_POWER);
 AnalogIn temp_pin_read(TEMP_PIN_READ);
 
@@ -249,10 +252,11 @@
 */
  
   // Print a start message
-  printf("%s","Simple LoRa temperature sensor\n");
-  printf("%s","--------------------------------\n");
-  printf("%s","---- VERSION NUCLEO STM32-------\n");
-  printf("%s","--------------------------------\n");
+  printf("%s","-------------------------------------------------\n");
+  printf("%s","------Simple LoRa temperature sensor-------------\n");
+  printf("%s","--P.Pharm, adaptation NUCELO STM32 C.Dupaty------\n");
+  printf("%s","-------------------------------------------------\n");
+ 
 #ifdef ARDUINO_AVR_PRO
   printf("%s","Arduino Pro Mini detected\n");  
 #endif
@@ -456,10 +460,10 @@
       for (int i=0; i<10; i++) {
           // change here how the temperature should be computed depending on your sensor type
           // 
-           value = temp_pin_read;
-          temp += (value*TEMP_SCALE/1024.0)/10;
+           value = temp_pin_read.read_u16();
+          temp += ((double)value*50.0/8192.0);
         
-          printf("%s","Reading ");
+          printf("%s","Reading ADC temperature -> ");
           printf("%d", value);
           printf("\n");   
           wait_ms(100);
@@ -467,7 +471,7 @@
       
 #ifdef LOW_POWER
       //digitalWrite(TEMP_PIN_POWER,LOW);
-      temp_pin_ower=0;
+      temp_pin_power=0;
 #endif
 
       printf("%s","Mean temp is ");