on my code i can send an sms to my target number but i don't know how to read or receive sms from target number
the tinyGSM library doesn't have the read member function and i don't know how to use AT commands
void setup() {
// Set console baud rate
SerialMon.begin(115200);
// Keep power when running from battery
Wire.begin(I2C_SDA, I2C_SCL);
bool isOk = setPowerBoostKeepOn(1);
SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL"));
// Set modem reset, enable, power pins
pinMode(MODEM_PWKEY, OUTPUT);
pinMode(MODEM_RST, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
digitalWrite(MODEM_RST, HIGH);
digitalWrite(MODEM_POWER_ON, HIGH);
// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(3000);
// Restart SIM800 module, it takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println("Initializing modem...");
modem.restart();
// use modem.init() if you don't need the complete restart
// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
modem.simUnlock(simPIN);
}
// To send an SMS, call modem.sendSMS(SMS_TARGET, smsMessage)
String smsMessage = "Hello from ESP32!";
/*if(modem.sendSMS(SMS_TARGET, smsMessage))
{
SerialMon.println(smsMessage);
}
else{
SerialMon.println("SMS failed to send");
}*/
SerialAT.println("AT"); //Once the handshake test is successful, it will back to OK
SerialAT.println("AT+CMGF=1"); // Configuring TEXT mode
SerialAT.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
}
void loop()
{
//readSMS(1);
//delay(1);
}
hello, good day, I am making an example with a 5500 chip in esp32 with the socketioclient library, but when I want to send the json to my server, they are only left on the waiting list and I don't know what is happening to me, before all this an error message about invalid mbox appeared and I added the following line of code esp_netif_init(); and it was fixed, but once entering the loop the following happens:
serial monitor:
Starting WebServer on ESP32 with W5x00 using Ethernet_Generic Library with Large Buffer
Ethernet_Generic v2.4.0
[ETG] Default SPI pinout:
[ETG] MOSI: 23
[ETG] MISO: 19
[ETG] SCK: 18
[ETG] SS: 5
[ETG] =========================
[ETG] ESP32 setCsPin: 5
[ETG] W5100 init, using SS_PIN_DEFAULT = 22 , new ss_pin = 10 , W5100Class::ss_pin = 5
[ETG] Chip is W5500
[ETG] W5100::init: W5500, SSIZE = 8192
[ETG] Currently Used SPI pinout:
[ETG] MOSI: 23
[ETG] MISO: 19
[ETG] SCK: 18
[ETG] SS: 5
[ETG] =========================
Using mac index = 1
Connected! IP address: 192.168.10.147
Speed: 100 MB, Duplex: FULL DUPLEX, Link status: LINK
LLego a la parte de initwebsocket y task
termino inits
[SIoC] add packet 42["setRele",{"Dato":"hola"}]
[SIoC] add packet 42["getPrueba",{"name":"hola ese","SERVIDOR":"HOLA MUNDO"}]
[SIoC] Disconnected!
[SIoC] add packet 42["setRele",{"Dato":"hola"}]
[SIoC] add packet 42["getPrueba",{"name":"hola ese","SERVIDOR":"HOLA MUNDO"}]
[SIoC] Disconnected!
[SIoC] add packet 42["setRele",{"Dato":"hola"}]
[SIoC] add packet 42["getPrueba",{"name":"hola ese","SERVIDOR":"HOLA MUNDO"}]
[SIoC] Disconnected!
then the loop remains without emitting it just remains as shown above
sketch:
/****************************************************************************************************************************
WebServer.ino
Ethernet_Generic is a library for the W5x00 Ethernet shields trying to merge the good features of
previous Ethernet libraries
Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Generic
*****************************************************************************************************************************/
/*
The Arduino board communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the Uno
and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used as SS. On the Mega, the hardware SS pin, 53,
is not used to select the Ethernet controller chip, but it must be kept as an output or the SPI interface won't work.
*/
#include "defines.h"
#include <SocketIoClient.h>
#include <Arduino_JSON.h>
#include <tcpip_adapter.h>
//TaskHandle_t Task1;
SocketIoClient socketIO;
//void Task1code( void * parameter ){
// Serial.print("Task1 is running on core ");
// Serial.println(xPortGetCoreID());
// while(1){
// socketIO.loop();
// delay(100);
// }
//}
//
//
void initWebSocket()
{
// server address, port and URL
socketIO.begin("192.168.10.59",8000);
// event handler for the event message
socketIO.on("asignacion",getresponse);
//socketIO.on("getPrueba",getresponse);
socketIO.loop();
delay(5000);
}
void getresponse(const char *payload, size_t length){
Serial.printf("response: ",payload);
String data = String(payload);
data.replace("\\","");
JSONVar dato = JSON.parse(data);
Serial.println(dato["litros"]);
}
void setup()
{
Serial.begin(115200);
while (!Serial && millis() < 5000);
Serial.print("\nStarting WebServer on "); Serial.print(BOARD_NAME);
Serial.print(F(" with ")); Serial.println(SHIELD_TYPE);
Serial.println(ETHERNET_GENERIC_VERSION);
#if (USING_SPI2)
#if defined(CUR_PIN_MISO)
ETG_LOGWARN(F("Default SPI pinout:"));
ETG_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI);
ETG_LOGWARN1(F("MISO:"), CUR_PIN_MISO);
ETG_LOGWARN1(F("SCK:"), CUR_PIN_SCK);
ETG_LOGWARN1(F("SS:"), CUR_PIN_SS);
ETG_LOGWARN(F("========================="));
#endif
#else
ETG_LOGWARN(F("Default SPI pinout:"));
ETG_LOGWARN1(F("MOSI:"), MOSI);
ETG_LOGWARN1(F("MISO:"), MISO);
ETG_LOGWARN1(F("SCK:"), SCK);
ETG_LOGWARN1(F("SS:"), SS);
ETG_LOGWARN(F("========================="));
#endif
#if defined(ESP32)
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
#endif
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 5 //22 // For ESP32
#endif
ETG_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN);
// Must use library patch for Ethernet, EthernetLarge libraries
// ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge
// ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3
//Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (USE_THIS_SS_PIN);
// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//Ethernet.begin(mac[index], ip);
Ethernet.begin(mac[index]);
//SPIClass SPI2(HSPI);
//Ethernet.begin(mac[index], &SPI2);
// Just info to know how to connect correctly
// To change for other SPI
#if defined(CUR_PIN_MISO)
ETG_LOGWARN(F("Currently Used SPI pinout:"));
ETG_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI);
ETG_LOGWARN1(F("MISO:"), CUR_PIN_MISO);
ETG_LOGWARN1(F("SCK:"), CUR_PIN_SCK);
ETG_LOGWARN1(F("SS:"), CUR_PIN_SS);
ETG_LOGWARN(F("========================="));
#else
ETG_LOGWARN(F("Currently Used SPI pinout:"));
ETG_LOGWARN1(F("MOSI:"), MOSI);
ETG_LOGWARN1(F("MISO:"), MISO);
ETG_LOGWARN1(F("SCK:"), SCK);
ETG_LOGWARN1(F("SS:"), SS);
ETG_LOGWARN(F("========================="));
#endif
Serial.print(F("Using mac index = "));
Serial.println(index);
Serial.print(F("Connected! IP address: "));
Serial.println(Ethernet.localIP());
if ( (Ethernet.getChip() == w5500) || (Ethernet.getAltChip() == w5100s) )
{
Serial.print(F("Speed: ")); Serial.print(Ethernet.speedReport());
Serial.print(F(", Duplex: ")); Serial.print(Ethernet.duplexReport());
Serial.print(F(", Link status: ")); Serial.println(Ethernet.linkReport());
}
Serial.println("LLego a la parte de initwebsocket y task");
Serial.println("termino inits");
// tcpip_adapter_init();
// for (int i = TCPIP_ADAPTER_IF_STA; i < TCPIP_ADAPTER_IF_MAX; i++) {
// if (tcpip_adapter_is_netif_up((tcpip_adapter_if_t)i))
// ESP_LOGI(TAG, "interface %i up ", i);
// else
// ESP_LOGI(TAG, "interface %i down ", i);
// }
esp_netif_init();//ojo con esta funcion https://gitter.im/espressif/arduino-esp32?at=607b291f06e2e024e85cdf50
initWebSocket();
// xTaskCreatePinnedToCore(Task1code,"Task1",10000,NULL,1,&Task1,0);
}
void loop()
{
//socketio.loop();
//socketIO.emit("getPrueba","{\"hello world\"}");
//socketIO.emit("plainString", "\"this is a plain string\"");
socketIO.emit("setRele","{\"Dato\":\"hola\"}");
delay(500);
//socketIO.emit("app","{\"name\":\"hola ese\",\"chava\":\"hola chava\"}");//esta libreria solo maneja archivos json
socketIO.emit("getPrueba","{\"name\":\"hola ese\",\"SERVIDOR\":\"HOLA MUNDO\"}");
//socketIO.emit("setData","{\"Dato\":\"hola\",\"Dato2\":\"Andre\"}");
//socketIO.on("get",getresponse);
delay(500);
socketIO.loop();
}
i only use two events to emit to the server they are setRele and getprueba as shown in the loop
server java script:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http,{allowEIO3: true ,cors: {origins: ['http://localhost:4200', 'http://localhost']}});
var port = process.env.PORT || 8080;
app.get('/', (req, res) => {
console.log("app works");
});
io.on('connection', (socket) => {
console.log(socket.id);
/**Catalogos */
// socket.emit("GetConfiguracion","{\"code\":\"ECOA-0179\",\"cambio\":\"0\",\"idRespuesta\":\"1\",\"Pines\":[{},{}]}");
// socket.emit("Reiniciar","{\"CodigoMDC\":\"ECOA-0179\"}");
// socket.emit("SetRelee","{\"code\":\"ECOA-0179\",\"f\":\"2022/04/26 03:51:33\",\"p\":\"26\",\"v\":\"1.00\"}");
socket.on("stateChanged", (params) => {
console.log(params); // x8WIv7-mJelg7on_ALbx
});
socket.on("getPrueba", (params) => {
console.log(params); // x8WIv7-mJelg7on_ALbx
});
socket.on("setRele", (params) => {
console.log(params); // x8WIv7-mJelg7on_ALbx
//socket.emit("SetRelee","{\"code\":\"ECOA-0179\",\"f\":\"2022/04/26 03:51:33\",\"p\":\"26\",\"v\":\"1.00\"}");
});
socket.on("ConfiguracionAplicada", (params) => {
console.log(params); // x8WIv7-mJelg7on_ALbx
});
socket.on('disconnect', () =>
{
console.log("Desconectado id: ",socket.id);
});
});
http.listen(port, () => {
console.log('listening on :' + port);
});
If someone could help me, it would be very helpful. Thank you. I'm new to ethernet connectivity. I hope you understand.
At the moment I try to send packets between one Heltec WIFI LoRa V2 and another by reading the serial-line and sending the input via LoRa.
Small packets (like 30 bytes) work every time, but as bigger the packet gets the packet won't be received every time or even never.
So I write a little sending loop, where my sender sends at every iteration a packet, which gets every time 10 byte bigger, and surprisingly every packet was received by the sender (I tried that until 500 bytes).
After that, I wanted to send a 80 byte serial input message and this did not work. Do you know what's the problem with that?
void setup() {
// ... LoRa.begin(); ....
LoRa.onReceive(onReceive);
// ... LoRa.receive(); ...
}
void onReceive(int packetSize) { // uses the interrupt pin on the dio0
String packet = "";
packSize = String(packetSize,DEC);
for (int i = 0; i < packetSize; i++) {
packet += (char) LoRa.read();
}
Serial.println(packet);
delay(5);
} ```
``` // writer
boolean sendPacket (String packet) {
Serial.println("Send begin");
LoRa.beginPacket(false); // true: optional implicit mode (--> Set everything on both sides?!)
LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
LoRa.print(packet); // also LoRa.write(byte(, length));
LoRa.endPacket(false); // true: async mode: doas not wair until transmission is completed
delay(250);
// put the radio into receive mode
LoRa.receive(); // set redio back in receive mode
delay(750);
Serial.println("Send end");
return true; // will be changed
}
void loop(){
while(Serial.available() > 0 ){
delay(2); //delay to allow byte to arrive in input buffer
String text = Serial.readString();
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
boolean packetSent = false;
while (!packetSent) {
packetSent = sendPacket(text);
if (packetSent) {
Serial.print("Packet has been sent: ");
Serial.println(text);
} else {
Serial.print("Retry sending packet: ");
Serial.println(text);
}
}
digitalWrite(LED, LOW); // turn the LED off (HIGH is the voltage level)
}
} ```
Basically, my project uses a force-sensing resistor to detect occupancy on the chair. The ESP8266 WiFi would wake from the sleep mode and send an update to the server. If there is no occupancy, the ESP8266 goes back to sleep.
My project uses Wiolink, a dev board that uses a ESP8266 WiFi chip. Hence, it is quite impossible to connect GPIO 16 to RST to wake up ( or reset ) the device.
Deep sleep is predefined at a set amount of time using this function ESP.deepsleep(). Is it possible to wake up with an external interrupt such as the force sensing resistor?
String apiKey = ""; // const char* ssid = ""; // wifi username const
char* password = ""; // wifi password
void setup() // Defines the initial condition of the hardware board.
{
Serial.begin(115200); delay(10);
}
void loop() // Defines the loop condition of the hardware board. {
sensorReading = analogRead(A0);
if(sensorReading >= 150) // Condition when someone is sitting;
{
//Wake ESP8266
//perform server update
}
if(sensorReading <=149) // Condition for no one sitting;
{
Serial.println("Going into deep sleep");
ESP.deepSleep(); //
}
Hi I'm new to kernel level programming and trying to build a simple log writing driver. What I'm trying to achieve is to have a persistent driver will write referred text every predefined interval to a file in system path. (I'm not familiar IRQ hooking yet)
I have following globals for timing
// Timer
PKTIMER pTimer = NULL; // Pointer to the timer
PKDPC pDpcObject = NULL; // Pointer to the DPC
#define IDLE_INTERVAL (10000)
I call following code in the DriverEntry (However, problem with following code is its writing feature fails when computer restarted) Could someone suggest a fix ? Should it be called by IRQ Major call ?
while(1)
{
if (pTimer == NULL) // if timer object does not exist:
{
// Allocate memory for the object timer
pTimer = (PKTIMER) ExAllocatePool (NonPagedPool, sizeof (KTIMER));
KeInitializeTimer (pTimer); // Initialize the timer object
// Allocate memory for the DPC object and initialize it
pDpcObject = (PKDPC) ExAllocatePool (NonPagedPool, sizeof (KDPC));
KeInitializeDpc (pDpcObject, MyDeferredRoutine, pTimer);
}
LARGE_INTEGER dueTime;
dueTime.QuadPart = -10000 * IDLE_INTERVAL; // 10000 * 10000 * 1 ns
// "Platoon" timer:
KeSetTimerEx (pTimer,
dueTime, // latency relative interval
(IDLE_INTERVAL / 2), // period of 5 seconds, i.e. 5000 * 1 ms
pDpcObject);
if (KeReadStateTimer (pTimer))
{
//DbgPrint ("- Example- KeReadStateTimer returns TRUE.");
}
else
{
// DbgPrint ("- Example- KeReadStateTimer returns FALSE.");
}
}
Status = KeWaitForSingleObject (pTimer,
Executive, // IN KWAIT_REASON WaitReason,
KernelMode, // IN KPROCESSOR_MODE WaitMode,
FALSE, // IN BOOLEAN Alertable,
NULL); // IN PLARGE_INTEGER Timeout OPTIONAL
RtlInitUnicodeString(&TestName, L"\\??\\C:\\log.txt");
InitializeObjectAttributes(&ObjAttr, &TestName,
OBJ_CASE_INSENSITIVE,
0, NULL);
Status = NtCreateFile(&TestFile,
FILE_WRITE_DATA + SYNCHRONIZE,
&ObjAttr,
&IoStatus, NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL, 0);
if(Status == STATUS_SUCCESS)
{
Status = NtWriteFile(TestFile,
0, NULL, NULL,
&IoStatus,
(PCHAR)"OUR LOG STORED TO LOG FILE",
22,
NULL, NULL);
}
NtClose(TestFile);
}