Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32 with SIMCOM A7672s IoT Sensor Data Logger

View and Edit Project In Cirkit DesignerImage of ESP32 with SIMCOM A7672s IoT Sensor Data Logger

Circuit Documentation

Summary of the Circuit

This circuit integrates an ESP32 with SIMCOM A7672s module and an LM393 comparator. The ESP32 module is responsible for processing data and communicating with the Blynk Cloud via the SIMCOM A7672s module, which provides cellular connectivity. The LM393 is used as a sensor input to the ESP32, which reads the sensor's digital output and sends this data to the Blynk Cloud for remote monitoring.

Component List

ESP32 with SIMCOM A7672s

LM393

Wiring Details

ESP32 with SIMCOM A7672s

LM393

Documented Code

/* Written by Jacques Wilken
 * This sketch reads data from an LM393 sensor connected to an Lilygo T-SIM7000G ESP32 Module
 * and sends the data to Blynk Cloud using the SIMCOM A7672s module with TinyGSM.
 */

#define BLYNK_TEMPLATE_ID "TMPL2wMpNHE7e"
#define BLYNK_TEMPLATE_NAME "DHT11"
#define BLYNK_AUTH_TOKEN "2LPgcbcbnucoG9tmgXwAbykiGEXt5_b-"

// Select your modem:
#define TINY_GSM_MODEM_SIM7000   // SIMA7000 Compatible with SIM7000 AT instructions

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>

// Set serial for debug console (to the Serial Monitor)
#define SerialMon Serial

// Set serial for AT commands (to the module)
#define SerialAT Serial1

// Your GPRS credentials
// Leave empty, if missing user or pass
const char apn[]  = "mymtn";
const char user[] = "";
const char pass[] = "";

// Pin definitions
const int lm393Pin = 27; // LM393 D0 connected to ESP32 GPIO 27

// Blynk auth token
char auth[] = BLYNK_AUTH_TOKEN;

TinyGsm modem(SerialAT);

void setup() {
  // Set console baud rate
  SerialMon.begin(115200);
  delay(10);

  // Set module baud rate
  SerialAT.begin(9600);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  SerialMon.println("Initializing modem...");
  if (!modem.restart()) {
    SerialMon.println("Failed to restart modem, attempting to initialize...");
    if (!modem.init()) {
      SerialMon.println("Failed to initialize modem");
      while (true); // Halt execution
    }
  }

  // Unlock your SIM card with a PIN if needed
  // modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);

  // Check if connected to Blynk
  if (!Blynk.connected()) {
    SerialMon.println("Failed to connect to Blynk");
    while (true); // Halt execution
  }

  // Initialize the LM393 pin
  pinMode(lm393Pin, INPUT);
}

void loop() {
  // Read the LM393 sensor value
  int sensorValue = digitalRead(lm393Pin);

  // Send the sensor value to Blynk
  Blynk.virtualWrite(V1, sensorValue);

  // Run Blynk
  Blynk.run();
}

This code is designed to be uploaded to the ESP32 with SIMCOM A7672s module. It initializes the modem, connects to the Blynk Cloud, and reads the digital output from the LM393 sensor. The sensor value is then sent to the Blynk Cloud for remote monitoring. The lm393Pin is defined as GPIO 27, which corresponds to the wiring between the ESP32 and the LM393.