Bernard 7 Posted June 25, 2014 Share Posted June 25, 2014 Hi, Here is a working example TM4C129 using Enrf24 library /* Tiva launchpad connected TM4C129 nRF24L01 RX SPI module 2 25/06/2014 */ #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> Enrf24 radio(PE_0,PE_2,PE_1); // CE, CSN, IRQ + SCK/MOSI/MISO ==> PD_3/PD_0/PD_1 const uint8_t rxaddr[] = { 0xF0,0xF0,0xF0,0xF0,0xE1 }; unsigned long prev_time; void setup() { Serial.begin(9600); Serial.flush(); SPI.setModule(2); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); radio.begin(); // Defaults 1Mbps, channel 0, max TX power dump_radio_status_to_serialport(radio.radioState()); radio.setRXaddress((void*)rxaddr); radio.enableRX(); // Start listening delay(100); } void loop() { char inbuf[33]; delta_set(); while (!radio.available(true)&& delta_get()<1000); if (radio.read(inbuf)) { Serial.println(inbuf); } } void delta_set() { prev_time = millis(); } // TimeOut unsigned long delta_get() { unsigned long time; unsigned long delta; time = millis(); if (time < prev_time) { // TimeOut delta = 0xffffffff - prev_time + time + 1; } else { delta = time - prev_time; } return delta; } void dump_radio_status_to_serialport(uint8_t status) { Serial.print("Enrf24 radio transceiver status: "); switch (status) { case ENRF24_STATE_NOTPRESENT: Serial.println("NO TRANSCEIVER PRESENT"); break; case ENRF24_STATE_DEEPSLEEP: Serial.println("DEEP SLEEP <1uA power consumption"); break; case ENRF24_STATE_IDLE: Serial.println("IDLE module powered up w/ oscillators running"); break; case ENRF24_STATE_PTX: Serial.println("Actively Transmitting"); break; case ENRF24_STATE_PRX: Serial.println("Receive Mode"); break; default: Serial.println("UNKNOWN STATUS CODE"); } } TX is MSP430 + DHT22 sending humidity and temperature Salutations Bernard Rickta59, energia and spirilis 3 Quote Link to post Share on other sites
spirilis 1,265 Posted June 25, 2014 Share Posted June 25, 2014 Awesome, thanks! I have one of my nRF24 bpaks on my Tiva Connected LP at home but haven't got around to trying it yet... This will help a lot :-) Quote Link to post Share on other sites
energia 485 Posted June 25, 2014 Share Posted June 25, 2014 Awesome. Thanks for sharing! Quote Link to post Share on other sites
Bernard 7 Posted June 25, 2014 Author Share Posted June 25, 2014 Hi again, I forgot to post the TX side : /* MSP 430g2553 TX DHT22 25/06/2014 */ #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> #include <DHT22_430.h> #define DHTPIN P1_4 DHT22 mySensor(DHTPIN); Enrf24 radio(P2_0, P2_1, P2_2); // P2.0=CE, P2.1=CSN, P2.2=IRQ const uint8_t txaddr[] = { 0xF0,0xF0,0xF0,0xF0,0xE1 }; boolean flag = 0; void dump_radio_status_to_serialport(uint8_t); void setup() { Serial.begin(9600); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); // MSB-first mySensor.begin(); radio.begin(); // Defaults 1Mbps, channel 0, max TX power //radio.setCRC(1,1); radio.setTXaddress((void*)txaddr); } void loop() { char str[16]; long h = mySensor.humidityX10(); long t = mySensor.temperatureX10(); flag = mySensor.get(); if (!flag) { radio.print("DHT error"); } else{ sprintf(str, "%ld",h/10); radio.print(str); radio.print("."); sprintf(str, "%ld",h%10); radio.print(str); radio.print("---"); sprintf(str, "%ld",t/10); radio.print(str); radio.print("."); sprintf(str, "%ld",t%10); radio.print(str); radio.flush(); // Force transmit (don't wait for any more data) } delay(1000); } My project is to centrally manage several rf sensors on Tiva connected board and make a web server. I have spent many time to add the Ethernet part in the loop and so far no success ... any help would be appreciate Salutations Bernard Rickta59 1 Quote Link to post Share on other sites
bobnova 59 Posted July 3, 2014 Share Posted July 3, 2014 Great to see this, I have a couple of those radios headed my way from China right now. Thanks! Quote Link to post Share on other sites
pane 0 Posted April 9, 2016 Share Posted April 9, 2016 Hi, I was not able to make TM4C129 transmit but finally it works. Before you give up when only Rx is working but no Tx (even if your module is working with MSP430 and TM4C123 correctly try to INSTALL BYPASS CAPACITOR on the module (e.g. 10uf capacitor directly over VCC and GND). P Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.