How to connect TI - CC1101 to NodeMCU Board - nodemcu

I'm trying to get the TI-CC1101 433 MHz Transceiver Module to work with my NodeMCU ESP8266 but I am not sure about the wiring.
Link to the data sheet: LINK
Heres is a link with picture:LINK
I only want to use this Transceiver as a receiver for now so that's my setup:
NodeMCU 3.3 Volt --> VIC of TI-CC110
GND --> GND
NodeMCU D4 (2 in Arduino IDE) --> SI pin of TI-CC110.
I tested the following code with another 433 MHz receiving unit and it worked.
It's the example code of the RC Link Library:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(2); // Receiver on interrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
} else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
}
mySwitch.resetAvailable();
}
}
I get nothing when I'm trying the new module wired the way described above.

Hello the rc switch library does not support the cc1101 module officially. but there is an external driver library which allows to use the cc1101 module with rcswitch. Currently the esp modules are not supported. an update for esp is in planning.
https://github.com/LSatan/RCSwitch-CC1101-Driver-Lib

Related

Trouble with sending data through Serial2 in esp32

I need to send hex data from esp32wroom to a relay module. The communication is via RS485. The RS485 module used in SN75H12VD.The Rx and Tx pins are 16 and 17 of esp32. The enable pin is connected to pin 4. I have made the enable pin HIGH. I tried to use hardwareserial. Used a serial terminal to check whether the data is being sent. But nothing is getting printed. I also tried Serial2. But no luck. Please find my code below. It would be great if someone could help me with this.
#include<Arduino.h>
#include <HardwareSerial.h>
#define RXD2 16
#define TXD2 17
#define enable_pin 4
HardwareSerial mySer(2);
void setup()
{
Serial.begin(115200);
Serial.println("hi");
mySer.begin(9600, SERIAL_8N1, RXD2, TXD2);
pinMode(RXD2, INPUT);
pinMode(TXD2, OUTPUT);
pinMode(enable_pin, OUTPUT);
delay(10);
digitalWrite(enable_pin, HIGH);
}
void loop()
{
if (!mySer)
{ // If the object did not initialize, then its configuration is invalid
Serial.println("Invalid pin configuration, check config");
while (1) { // Don't continue with invalid configuration
delay (1000);
}
}
else {
Serial.println("hello");
mySer.println("hey");
mySer.write(0x13);
mySer.write(0x01);
mySer.write(0x03);
mySer.write(0x40);
mySer.write(0x02);
mySer.write(0x01);
mySer.write(0x00);
mySer.write(0xC9);
mySer.write(0x80);
mySer.write(0x0A);
delay(2000);
mySer.write(0x13);
mySer.write(0x01);
mySer.write(0x03);
mySer.write(0x40);
mySer.write(0x02);
mySer.write(0x00);
mySer.write(0x00);
mySer.write(0xC8);
mySer.write(0x10);
mySer.write(0x0A);
delay(2000);`enter code here`
}
}

Comunicazione NDEF

I'm working on a mobile app and my intent is to make the Arduino communicate with the smartphone. so far I can only read the first message sent by the arduino, when the application is not active.
I'm using this function of react-native-nfc-manager library:
getLaunchTagEvent ()
After this event I can no longer read other NDEF messages. how can i solve?
The code is as follows:
componentDidMount(){
NfcManager.isSupported()
.then(supported => {
this.setState({ supported });
if (supported) {
this._startNfc();
}
})
}
_startNfc() {
if (Platform.OS === 'android') {
NfcManager.getLaunchTagEvent()
.then(tag => {
console.log('launch tag', tag);
if (tag) {
this.setState({ tag });
}
})
.catch(err => {
console.log(err);
})
}
}
Also i am trying to read the tag with the application open, but the action fails on the arduino. solutions?
The code is as follows:
readData = async () => {
NfcManager.registerTagEvent(
tag => {
console.log('Tag Discovered', tag);
},
'Hold your device over the tag',
{
readerModeFlags:
NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK,
readerModeDelay: 2,
},
);
}
The Arduino code is as follows:
#include "SPI.h"
#include "PN532_SPI.h"
#include "snep.h"
#include "NdefMessage.h"
PN532_SPI pn532spi(SPI, 10);
SNEP nfc(pn532spi);
uint8_t ndefBuf[128];
void setup() {
Serial.begin(9600);
Serial.println("NFC Peer to Peer-Send Message");
}
void loop() {
Serial.println("Send a message to Peer");
NdefMessage message = NdefMessage();
message.addTextRecord("Hello");
int messageSize = message.getEncodedSize();
if (messageSize > sizeof(ndefBuf)) {
Serial.println("ndefBuf is too small");
while (1) {
}
}
message.encode(ndefBuf);
if (0 >= nfc.write(ndefBuf, messageSize)) {
Serial.println("Failed");
} else {
Serial.println("Success");
}
delay(3000);
}
The uses of SNEP (and LLCP) complicates things as this is a peer to peer protocol and peer to peer has been deprecated in Android 10 and not supported in iOS and I'm not so familiar with it.
I'm not sure it is possible read SNEP messages using enableReaderMode (this is what you have asked react-native-nfc-manager library to use).
This is because SNEP and (LLCP) is not a TYPE A technology type
If you look at the NFC standards diagram at https://pdfslide.net/documents/divnfc0804-250-nfc-standards-v18.html
It might be a TYPE F technology type so I would try instead of NfcAdapter.FLAG_READER_NFC_A I would use NfcAdapter.FLAG_READER_NFC_F or enable all of the technologies to be on the safe side (though I think this might not work as well)
But if this does not work, normally with Android Peer to Peer it expects only to be sent NDEF messages and you have disabled the System NFC App from processing NDEF messages with NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK so I would try removing that and work with the Ndef tag technology type.
But I don't think any of that will help, the next thing I would try is to not use enableReaderMode with react-native-nfc-manager but use the underlying enableForgroundDispatch methods by just by specifying NfcManager.registerTagEvent();.
As this interacts with the Android System NFC App at a later point in the chain of events where the Android System NFC App is creating Intents to share with other Apps either to Launch an App to handle the Intent or pass it to a running App that has asked to be sent NFC Intents.
As this looks to be a common point between how the Android System NFC App handles real NFC Tags and Peer to Peer SNEP messages as a SNEP message can launch your App.
But going forward I would not use SNEP (peer to peer) as this is deprecated but get the Arduino to do Host Card Emulation to send the data (Then you could use Reader Mode)

Arduino speaker using sd card code error

I have basically connected a speaker to Arduino uno board. I just need help with the code. I have used the TMRpcm library to make it easier. However, it seems to be giving me an error everytime. here is the code below.
include "SD.h"
define SD_ChipSelectPin 10
include "TMRpcm.h"
include "SPI.h"
TMRpcm audio;
void setup(){
audio.speakerPin = 9;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}
audio.setVolume(10);
audio.play("Spring_In_My_Step_-_Silent_Partner_Mp3Converter_ne.wav");
}
void loop()
{
}
any and all help is appreciated
thank you!

Solving "redeclared as different kind of symbol" error

I'm currently working on Arduino. I'm working for Lamp using Atmega1284. I saw an example code, ModbusIP_ENC28J60 -> Lamp. I first compiled it without adding anything, it compiled properly. Now, I'm adding WebSocketServer, since I want this to work on websocket too. I added few necessary lines, but I ended up with this error:
error: 'EthernetClass Ethernet' redeclared as different kind of symbol
I don't understand what's wrong with the code or what I should change. Can someone help me with this?
I'm pasting my code here for reference:
#include <EtherCard.h>
#include <Modbus.h>
#include <ModbusIP_ENC28J60.h>
#include <WebSocketsServer.h>
WebSocketsServer webSocketServer = WebSocketsServer(8080);
//Modbus Registers Offsets (0-9999)
const int LAMP1_COIL = 100;
//Used Pins
const int ledPin = 9;
//ModbusIP object
ModbusIP mb;
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
switch(type) {
case WStype_DISCONNECTED:
Serial.println("[%u] Disconnected!\n");
break;
case WStype_CONNECTED:
{
//IPAddress ip = webSocket.remoteIP(num);
Serial.println("[%u] Disconnected!\n");
// send message to client
//webSocket.sendTXT(num, "Connected");
}
break;
case WStype_TEXT:
Serial.println("[%u] got text!\n");
// send message to client
// webSocket.sendTXT(num, "message here");
// send data to all connected clients
// webSocket.broadcastTXT("message here");
break;
case WStype_BIN:
Serial.println("[%u] get binary ");
//hexdump(payload, lenght);
// send message to client
// webSocket.sendBIN(num, payload, lenght);
break;
}
}
void setup() {
// The media access control (ethernet hardware) address for the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// The IP address for the shield
byte ip[] = { 192, 168, 0, 120 };
//Config Modbus IP
mb.config(mac, ip);
//Set ledPin mode
pinMode(ledPin, OUTPUT);
// Add LAMP1_COIL register - Use addCoil() for digital outputs
mb.addCoil(LAMP1_COIL);
webSocketServer.begin();
webSocketServer.onEvent(webSocketEvent);
}
void loop() {
//Call once inside loop() - all magic here
mb.task();
//Attach ledPin to LAMP1_COIL register
digitalWrite(ledPin, mb.Coil(LAMP1_COIL));
webSocketServer.loop();
}
Help me to make it work.
You are declaring Ethernet twice. And they are different.
First is probably in the include file Ethercard.h
Second is Modbus.h
In the ModbusIP_ENC28J60 I found in github via Google they declare Ethernet as an array.
Either rename one declaration (e.g. ether vs Ethernet) or eliminate the use of one. Also, considering the include files in your source I would be surprised if there are only two conflicts.
C lesson: Declaring a variable for use by a function, very straightforward. When adding additional modules any name conflicts will cause problems. If you get two variables to agree but are still in the program you will suffer massive debugging headaches because one function will access its variable while the other will have its own, resulting in nothing actually working.
Go back and look at the source files (*.h). Search for "Ethernet" variables. See how they are declared and how they are used. The simplest solution is to pick the latest addition and change Ethernet to ether (as I suggested above).
Good Luck.

Using AODV in a wired simulation

I am trying to use AODV in a wired simulation but I can't make it work, is it possible to link 2 AODVRouters by wire and use the AODV protocol?? or should I use 2 standardhost and modify the AODVrouting.cc??
EDIT:
I just simulate the AODV simpleRREQ example using standardhosts instead of AODVrouters and using the debug mode it crashes in this piece of code:
void AODVRouting::sendAODVPacket(AODVControlPacket *packet, const L3Address& destAddr, unsigned int timeToLive, double delay)
{INetworkProtocolControlInfo *networkProtocolControlInfo = addressType->createNetworkProtocolControlInfo();
networkProtocolControlInfo->setHopLimit(timeToLive);
networkProtocolControlInfo->setTransportProtocol(IP_PROT_MANET);
networkProtocolControlInfo->setDestinationAddress(destAddr);
networkProtocolControlInfo->setSourceAddress(getSelfIPAddress());
// TODO: Implement: support for multiple interfaces
InterfaceEntry *ifEntry = interfaceTable->getInterfaceByName("AODV");
networkProtocolControlInfo->setInterfaceId(ifEntry->getInterfaceId());
UDPPacket *udpPacket = new UDPPacket(packet->getName());
udpPacket->encapsulate(packet);
udpPacket->setSourcePort(aodvUDPPort);
udpPacket->setDestinationPort(aodvUDPPort);
udpPacket->setControlInfo(dynamic_cast<cObject *>(networkProtocolControlInfo));
if (destAddr.isBroadcast())
lastBroadcastTime = simTime();
if (delay == 0)
send(udpPacket, "ipOut");
else
sendDelayed(udpPacket, delay, "ipOut");
}
How can I send the AODV packet throw all the ethernet ports of the router?

Resources