├── Projects ├── 433MHz │ ├── receiver.ino │ └── transmitter.ino ├── Alexa │ └── ESP32_ESP8266_2_Devices.ino ├── Arduino-GPS │ ├── GPS_Raw_Data.ino │ ├── NEO_6M_get_all_GPS_data.ino │ └── NEO_6M_get_location.ino ├── Arduino-JSON │ ├── Arduino_HTTP_GET_Client.ino │ └── Arduino_HTTP_POST_Client.ino ├── Arduino │ ├── Arduino_Anemometer_Wind_Sensor.ino │ ├── Arduino_BME280_Test.ino │ ├── Arduino_BME680.ino │ ├── Arduino_DS3231_OLED_Clock.ino │ ├── Arduino_DS3231_Set_Alarms.ino │ ├── Arduino_DS3231_Set_Get_Time.ino │ ├── Arduino_Display_the_LED_Brightness_on_a_LCD_16_2.ino │ ├── Arduino_LM35_LM335_LM34.ino │ ├── Arduino_LM35_LM335_LM34_with_OLED.ino │ ├── Arduino_Load_Cell │ │ ├── Arduino_Calibrate_Load_Cell.ino │ │ ├── Arduino_Digital_Scale.ino │ │ └── Arduino_Test_Load_Cell.ino │ ├── Arduino_MPU6050_Serial_Plotter.ino │ ├── Arduino_Multiple_DS18B20_Sensors.ino │ ├── Arduino_NEO_M8N_GPS_Raw_Data.ino │ ├── Arduino_NEO_M8N_GPS_TinyGPSPlus.ino │ ├── Arduino_RCWL_0516_Basic.ino │ ├── Arduino_TDS_Sensor.ino │ ├── Arduino_Thermocouple.ino │ ├── BH1750test.ino │ ├── DHT11_DHT22_LM35_DS18B20_BME280_BMP180.ino │ ├── ESP32_DHTtester.ino │ └── bmp3xx_simpletest_Arduino.ino ├── Arduino_Control_a_12V_Lamp_via_SMS.ino ├── Arduino_Daily_Task.ino ├── Arduino_Daily_Task_Set_RTC.ino ├── Arduino_Display_the_LED_Brightness_on_a_LCD_16x2.c ├── Arduino_EEPROM.ino ├── Arduino_Poor_mans_oscilloscope.c ├── Arduino_Poor_mans_oscilloscope_processing_code.c ├── Arduino_Relay_PIR_Guide.ino ├── Arduino_Temperature_Data_Logger.ino ├── Arduino_WS2812B_Color_Palette.ino ├── Arduino_microphone_sensor.ino ├── Arduino_tilt_sensor.ino ├── Arduino_with_Ethernet_Shield.c ├── Arduino_with_Keypad.ino ├── Arduino_with_PIR_motion_sensor.ino ├── BeagleBone │ ├── BBB-BoneScript-Web-Server │ │ ├── index.html │ │ └── server.js │ └── BBB-Surveillance-Python │ │ └── surveillance.py ├── Control_DC_motor_with_Smartphone_via_bluetooth.c ├── Control_LEDs_with_a_remote_control.c ├── Control_Servo_with_Visual_Basic.c ├── DHTtester.ino ├── DS18B20_Temperature_Sensor_Arduino.ino ├── DS18B20__ESP8266_web_server.ino ├── DeepSleep │ ├── deep_sleep_esp01.ino │ └── deep_sleep_esp12E.ino ├── Door_Status_Monitor_using_the_ESP8266.ino ├── ESP-IDF │ └── hello_world │ │ ├── blink_led.c │ │ └── hello_world.c ├── ESP-MicroPython │ ├── ESP32_Anemometer_Wind_Sensor.py │ ├── ESP32_ESP8266_Interact_GPIOs.py │ ├── ESP32_Read_GPS_Data.py │ ├── ESP32_Read_Raw_GPS_Data.py │ ├── ESP8266_Anemometer_Wind_Sensor.py │ ├── HCSR04 │ │ ├── hcsr04.py │ │ ├── main_basic.py │ │ └── main_oled.py │ ├── MQTT │ │ ├── esp_bme280_mqtt.py │ │ ├── esp_bme280_mqtt_flow.txt │ │ ├── esp_bme680_mqtt.py │ │ ├── esp_bme680_mqtt_flow.txt │ │ ├── esp_dht_mqtt.py │ │ ├── esp_dht_mqtt_flow.txt │ │ ├── esp_ds18b20_mqtt.py │ │ └── esp_ds18b20_mqtt_flow.txt │ ├── OTA_Updates_PHP │ │ ├── boot.py │ │ ├── main.py │ │ ├── program_1 │ │ │ └── program.py │ │ └── program_2 │ │ │ └── program.py │ ├── OTA_Updates_PHP_Alternative │ │ ├── main.py │ │ ├── program1.py │ │ └── program2.py │ ├── bh1750.py │ ├── bme680.py │ ├── dcmotor.py │ ├── esp32_ble_basic.py │ ├── esp32_esp8266_ws2812b.py │ ├── esp32_esp8266_ws2812b_individual.py │ ├── esp32_lolin32_ssd1306_oled.py │ ├── esp_access_point_boot.py │ ├── esp_asynchronous_programming.py │ ├── esp_bh1750_test.py │ ├── esp_blink_led_timer.py │ ├── esp_blink_relay.py │ ├── esp_blink_two_leds_timer.py │ ├── esp_bme280_readings.py │ ├── esp_bme280_web_server_boot.py │ ├── esp_bme280_web_server_main.py │ ├── esp_bme680.py │ ├── esp_bme680_web_server_boot.py │ ├── esp_bme680_web_server_main.py │ ├── esp_dcmotor.py │ ├── esp_debounce_pushbutton_timer.py │ ├── esp_deepsleep_bme280_boot.py │ ├── esp_dht_test.py │ ├── esp_dht_web_server_boot.py │ ├── esp_dht_web_server_main.py │ ├── esp_ds18b20.py │ ├── esp_ds18b20_web_server_boot.py │ ├── esp_ds18b20_web_server_main.py │ ├── esp_get_device_info.py │ ├── esp_rcwl_0516_main.py │ ├── esp_relay_web_server_boot.py │ ├── esp_relay_web_server_main.py │ ├── esp_send_email_bme280.py │ ├── esp_send_email_smtp.py │ ├── esp_send_message_whatsapp_main.py │ ├── esp_set_get_time_ds3231.py │ ├── esp_set_periodic_alarms_ds3231.py │ ├── esp_set_two_alarms_ds3231.py │ ├── esp_web_server_boot.py │ ├── esp_web_server_main.py │ ├── esp_wifimanager_example.py │ ├── interrupts_esp32_esp8266.py │ ├── lcd │ │ ├── custom_characters.py │ │ ├── lcd_api.py │ │ ├── machine_i2c_lcd.py │ │ ├── scrolling_text.py │ │ └── static_text.py │ ├── micropyGPS.py │ ├── oled │ │ ├── draw_shapes.py │ │ ├── gfx.py │ │ └── screen_scroll.py │ ├── umail.py │ ├── urtc.py │ └── wifimgr.py ├── ESP │ ├── ESP_Async_Web_Server_Display_Images.ino │ ├── ESP_Async_Web_Server_Display_Images_LittleFS.ino │ ├── ESP_Async_Web_Server_Display_Images_with_SPIFFS.ino │ ├── ESP_Blink_VS_Code.ino │ ├── ESP_Chart_Web_Server.zip │ ├── ESP_Chart_Web_Server │ │ ├── ESP_Chart_Web_Server.ino │ │ └── data │ │ │ └── index.html │ ├── ESP_Client_Server │ │ ├── ESP8266_Client_OLED_Display.ino │ │ ├── ESP8266_Client_OLED_Display_Multi_WiFi.ino │ │ ├── ESP8266_Server_Access_Point_AP_BME280.ino │ │ ├── ESP_Client_OLED_Display.ino │ │ └── ESP_Server_Access_Point_AP_BME280.ino │ ├── ESP_DS18B20_Async_Web_Server.ino │ ├── ESP_DS18B20_Multiple.ino │ ├── ESP_DS18B20_Single.ino │ ├── ESP_Email_Attachments │ │ ├── ESP_Email_Attachments.ino │ │ ├── ESP_Email_Attachments.zip │ │ └── data │ │ │ ├── image.png │ │ │ └── text_file.txt │ ├── ESP_Email_Simple.ino │ ├── ESP_Get_MAC_Address.ino │ ├── ESP_HTML_Form_Input_Data.ino │ ├── ESP_HTML_Form_Input_Data_Save_to_LittleFS.ino │ ├── ESP_HTML_Form_Input_Data_Save_to_SPIFFS.ino │ ├── ESP_InfluxDB_BME280.ino │ ├── ESP_InfluxDB_SecureWrite.ino │ ├── ESP_MPU6050_Basic_Demo.ino │ ├── ESP_MPU6050_Basic_OLED.ino │ ├── ESP_Mesh │ │ ├── ESP_Mesh_Basic.ino │ │ └── ESP_Mesh_Broadcast_Sensor_Readings.ino │ ├── ESP_NOW │ │ ├── ESP_NOW_Auto_Pairing │ │ │ ├── ESP32_Sender.ino │ │ │ ├── ESP32_Server.ino │ │ │ └── ESP8266_Sender.ino │ │ ├── ESP_NOW_Encryption │ │ │ ├── ESP32_Receiver_Encrypted.ino │ │ │ └── ESP32_Sender_Encrypted.ino │ │ ├── ESP_NOW_Receiver_ESP32.ino │ │ ├── ESP_NOW_Receiver_ESP8266.ino │ │ ├── ESP_NOW_Receiver_Multiple_Boards.ino │ │ ├── ESP_NOW_Sender_Multiple_Boards.ino │ │ ├── ESP_NOW_Sender_Multiple_Boards_Different_Messages.ino │ │ └── ESP_NOW_Sender_Multiple_Boards_Same_Messages.ino │ ├── ESP_Run_Daily_Task.ino │ ├── ESP_Run_Multiple_Daily_Tasks.ino │ ├── ESP_Send_Email │ │ ├── ESP_Send_Email.ino │ │ └── email-notification.php │ ├── ESP_Telegram │ │ ├── ESP32_Telegram_Motion.ino │ │ ├── ESP8266_Telegram_Motion.ino │ │ ├── ESP_Telegram_Control_Outputs.ino │ │ ├── ESP_Telegram_Group.ino │ │ └── ESP_Telegram_Request_Readings.ino │ ├── ESP_Thermostat_Web_Server.ino │ ├── ESP_Web_Server_Display_Images.ino │ ├── ESP_Web_Server_HTTP_Auth.ino │ ├── ESP_Web_Server_HTTP_Auth_2.ino │ ├── ESP_Web_Server_HTTP_Authentication.ino │ ├── ESP_Web_Server_Momentary_Switch.ino │ ├── ESP_Web_Server_Physical_Button.ino │ ├── ESP_Web_Server_Timer_Pulse.ino │ └── data.zip ├── ESP32-MQTT │ ├── ESP32_MQTT_Publish_Subscribe.ino │ └── Node_RED_Flow_ESP32_MQTT_Publish_Subscribe.txt ├── ESP32 │ ├── AsyncElegantOTA │ │ ├── ESP32_ElegantOTA_Demo │ │ │ └── ESP32_ElegantOTA_Demo.ino │ │ ├── ESP32_Web_Server_LED_OTA │ │ │ └── ESP32_Web_Server_LED_OTA.ino │ │ └── ESP32_Web_Server_OTA_SPIFFS │ │ │ ├── ESP32_Web_Server_OTA_SPIFFS.ino │ │ │ ├── data.zip │ │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── BLE │ │ ├── ESP32_BLE_Client.ino │ │ ├── ESP32_BLE_Notify_Receive.ino │ │ ├── ESP32_BLE_Server.ino │ │ ├── ESP32_WiFi_Provisioning_BLE.ino │ │ └── Web_BLE_App │ │ │ ├── favicon.ico │ │ │ ├── favicon.zip │ │ │ ├── index.html │ │ │ ├── index_no_css.html │ │ │ └── style.css │ ├── BLE_scan.ino │ ├── BLE_server.ino │ ├── BMP180_ESP32.ino │ ├── BMP388 │ │ ├── ESP32_BMP388_Datalogger.ino │ │ ├── ESP32_BMP388_Web_Server.ino │ │ └── bmp3xx_simpletest_ESP32.ino │ ├── ESP32_Anemometer_Wind_Sensor.ino │ ├── ESP32_Auto_Reconnect.ino │ ├── ESP32_BLE_Environmental_Sensing_Service.ino │ ├── ESP32_BME680.ino │ ├── ESP32_BME680_Web_Server.ino │ ├── ESP32_Blink_VS_Code.ino │ ├── ESP32_Car_Robot_Web_Server.ino │ ├── ESP32_Change_MAC_Address.ino │ ├── ESP32_Charts_Multiple_Series.zip │ ├── ESP32_Charts_Multiple_Series │ │ ├── ESP32_Charts_Multiple_Series.ino │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP32_DC_Motor.ino │ ├── ESP32_DC_Motor_Web_Server.ino │ ├── ESP32_DS3231_Alarms_Wake_Up_Deep_Sleep.ino │ ├── ESP32_DS3231_Set_Alarms.ino │ ├── ESP32_DS3231_Set_Get_Time.ino │ ├── ESP32_Datalogger_Download_File_Web_Server │ │ ├── ESP32_Datalogger_Download_File_Web_Server.ino │ │ └── index.html │ ├── ESP32_Date_Time.ino │ ├── ESP32_Digital_Inputs_Outputs.ino │ ├── ESP32_Door_Status_Monitor.ino │ ├── ESP32_Email │ │ ├── ESP32_Email_Attachments.ino │ │ ├── ESP32_Email_Attachments.zip │ │ ├── ESP32_Email_Simple.ino │ │ ├── ESP32_Email_Threshold_Web_Server.ino │ │ └── data │ │ │ ├── ESP32-CAM-Test.jpg │ │ │ └── text_file.txt │ ├── ESP32_Epoch_Unix_Time.ino │ ├── ESP32_Gauges │ │ ├── ESP32_Gauges.ino │ │ ├── ESP32_Gauges.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP32_Get_MAC_Address.ino │ ├── ESP32_Google_Sheets.ino │ ├── ESP32_HC_SR04.ino │ ├── ESP32_HC_SR04_OLED.ino │ ├── ESP32_HTTPS │ │ ├── ESP32_BasicHttpsClient_Certificate │ │ │ └── ESP32_BasicHttpsClient_Certificate.ino │ │ ├── ESP32_HTTPSClient_No_Certificate │ │ │ └── ESP32_HTTPSClient_No_Certificate.ino │ │ ├── ESP32_WiFiClientSecure_Certificate │ │ │ └── ESP32_WiFiClientSecure_Certificate.ino │ │ └── ESP32_WiFiClientSecure_No_Certificate │ │ │ └── ESP32_WiFiClientSecure_No_Certificate.ino │ ├── ESP32_I2C_Master.ino │ ├── ESP32_I2C_Slave.ino │ ├── ESP32_LILYGO_T_A7670G_HTTPS_GET.ino │ ├── ESP32_Light_Sleep │ │ ├── ESP32_Light_Sleep_Multiple_GPIOs_Wake_Up.ino │ │ ├── ESP32_Light_Sleep_Timer_Wake_Up.ino │ │ ├── ESP32_Light_Sleep_Touch_Wake_Up.ino │ │ ├── ESP32_Light_Sleep_UART_Wake_Up.ino │ │ ├── ESP32_Light_Sleep_ext0.ino │ │ └── ESP32_Light_Sleep_ext1.ino │ ├── ESP32_Load_Cell │ │ ├── ESP32_Calibrate_Load_Cell.ino │ │ ├── ESP32_Digital_Scale.ino │ │ └── ESP32_Test_Load_Cell.ino │ ├── ESP32_Lolin32_SSD1306_Oled.ino │ ├── ESP32_MPU_6050_Web_Server │ │ ├── ESP32_MPU_6050_Web_Server.ino │ │ ├── ESP32_MPU_6050_Web_Server.zip │ │ └── data │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP32_MQTT │ │ ├── ESP32_BME280.ino │ │ ├── ESP32_BME280_Flow.txt │ │ ├── ESP32_BME680.ino │ │ ├── ESP32_BME680_Flow.txt │ │ ├── ESP32_DHT.ino │ │ ├── ESP32_DHT_Flow.txt │ │ ├── ESP32_DS18B20.ino │ │ ├── ESP32_DS18B20_Flow.txt │ │ ├── ESP32_Test_Pub.ino │ │ └── ESP32_Test_Sub.ino │ ├── ESP32_MQTT_Subscribe_Control_Outputs.ino │ ├── ESP32_Multiple_DS18B20.ino │ ├── ESP32_Multiple_Sliders_Web_Server │ │ ├── ESP32_Multiple_Sliders_Web_Server.ino │ │ ├── ESP32_Multiple_Sliders_Web_Server.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP32_NEO_6M_GPS_Basic_Serial.ino │ ├── ESP32_NEO_6M_GPS_TinyGPS.ino │ ├── ESP32_NEO_M8N_GPS_Testing.ino │ ├── ESP32_NEO_M8N_GPS_TinyGPSPlus.ino │ ├── ESP32_NEO_M8N_GPS_TinyGPSPlus_Logger.ino │ ├── ESP32_NTPClient.ino │ ├── ESP32_Network_Events_CD.ino │ ├── ESP32_Pushover_Notifications.ino │ ├── ESP32_RCWL_0516_Basic.ino │ ├── ESP32_RFID │ │ ├── RFID_Read_Raw_Data.ino │ │ ├── RFID_Read_UID.ino │ │ └── RFID_Write_Read_Personal_Data.ino │ ├── ESP32_RFID_User_Management_WS │ │ ├── ESP32_RFID_User_Management_WS.ino │ │ ├── ESP32_RFID_User_Management_WS.zip │ │ └── data │ │ │ ├── add-user.html │ │ │ ├── full-log.html │ │ │ ├── get.html │ │ │ ├── manage-users.html │ │ │ └── style.css │ ├── ESP32_Read_Files_LittleFS.ino │ ├── ESP32_Relay_Control.ino │ ├── ESP32_Relay_Module_Web_Server.ino │ ├── ESP32_SIM800L_Cloud_MQTT_Broker.ino │ ├── ESP32_SIM800L_Cloud_MQTT_Broker_NodeRED.txt │ ├── ESP32_SIM800L_Data_to_Cloud.ino │ ├── ESP32_SIM800L_Send_SMS.ino │ ├── ESP32_SIM800L_Send_SMS_Temperature_Alert.ino │ ├── ESP32_Send_Messages_WhatsApp.ino │ ├── ESP32_Send_SMS_Twilio.ino │ ├── ESP32_Sensor_Readings_WebSocket │ │ ├── ESP32_Sensor_Readings_WebSocket.ino │ │ ├── ESP32_Sensor_Readings_WebSocket.zip │ │ └── data │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP32_Server_Sent_Events.ino │ ├── ESP32_Servo_Sweep.ino │ ├── ESP32_Set_Hostname.ino │ ├── ESP32_Slider_PWM.ino │ ├── ESP32_Stepper_Motor_Basic.ino │ ├── ESP32_Stepper_Motor_WS_Styled │ │ ├── ESP32_Stepper_Motor_WS_Styled.ino │ │ ├── ESP32_Stepper_Motor_WS_Styled.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ └── style.css │ ├── ESP32_Stepper_Motor_Web_Server.ino │ ├── ESP32_Stepper_Motor_Websocket │ │ ├── ESP32_Stepper_Motor_Websocket.ino │ │ ├── ESP32_Stepper_Motor_Websocket.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP32_TDS_Sensor.ino │ ├── ESP32_TTGO_LoRa_Receiver.ino │ ├── ESP32_TTGO_LoRa_Sender.ino │ ├── ESP32_Telegram_Door.ino │ ├── ESP32_Temperature_Data_Logging.ino │ ├── ESP32_Testing_LittleFS.ino │ ├── ESP32_Thermocouple.ino │ ├── ESP32_ThingSpeak_Multiple_Fields.ino │ ├── ESP32_ThingSpeak_Single_Field.ino │ ├── ESP32_Timezones.ino │ ├── ESP32_VS_Code_LittleFS_Test.ino │ ├── ESP32_WebSerial.ino │ ├── ESP32_WebSocket_Server.ino │ ├── ESP32_Web_Server_AP.ino │ ├── ESP32_Web_Server_Access_Point.ino │ ├── ESP32_Web_Server_Authentication.ino │ ├── ESP32_Web_Server_Control_Outputs.ino │ ├── ESP32_Web_Server_Display_Sensor_Readings.ino │ ├── ESP32_WiFiClientEvents.ino │ ├── ESP32_WiFiMulti.ino │ ├── ESP32_WiFiScan.ino │ ├── ESP32_WiFi_Manager │ │ ├── ESP32_WiFi_Manager.ino │ │ ├── ESP32_WiFi_Manager.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── style.css │ │ │ └── wifimanager.html │ ├── ESP32_WiFi_Signal_Strength.ino │ ├── ESP32_WiFi_Web_Server_Servo.ino │ ├── ESP32_Write_File_LittleFS.ino │ ├── ESP32_Write_File_LittleFS_Prevent_Overwrite.ino │ ├── ESP32_analogWrite.ino │ ├── ESP32_ledcWrite.ino │ ├── ESP3_LoRa │ │ ├── ESP3_LoRa.zip │ │ ├── LoRa_Receiver_Web_Server │ │ │ ├── LoRa_Receiver_Web_Server.ino │ │ │ └── data │ │ │ │ ├── index.html │ │ │ │ └── winter.jpg │ │ └── LoRa_Sender_BME280 │ │ │ └── LoRa_Sender_BME280.ino │ ├── ESPAsyncWebServer_library_example.ino │ ├── ESP_NOW │ │ ├── ESP_NOW_Receiver.ino │ │ ├── ESP_NOW_Sender.ino │ │ └── ESP_NOW_Two_Way_Communication.ino │ ├── ESP_NOW_WiFi │ │ ├── ESP_NOW_Receiver_Web_Server.ino │ │ └── ESP_NOW_Sender.ino │ ├── ElegantOTA │ │ ├── ESP32_WebServer_LED_ElegantOTA.ino │ │ ├── ESP32_WebServer_LED_ElegantOTA_2 │ │ │ ├── ESP32_WebServer_LED_ElegantOTA_2.ino │ │ │ ├── ESP32_WebServer_LED_ElegantOTA_2.zip │ │ │ └── data │ │ │ │ ├── favicon.png │ │ │ │ ├── index.html │ │ │ │ └── style.css │ │ └── ElegantOTA_Basic.ino │ ├── Find_DS18B20_Addresses.ino │ ├── HTTP │ │ ├── ESP32_HTTP_GET_JSON.ino │ │ ├── ESP32_HTTP_GET_Open_Weather_Map.ino │ │ ├── ESP32_HTTP_GET_Think_Speak.ino │ │ ├── ESP32_HTTP_GET_Update.ino │ │ ├── ESP32_HTTP_POST.ino │ │ ├── ESP32_HTTP_POST_IFTTT.ino │ │ ├── ESP32_HTTP_POST_Think_Speak.ino │ │ └── HTTP_NodeRED_Flow.txt │ ├── HTTPS_ESP32_Send_Email_PHP.ino │ ├── I2C │ │ ├── ESP32_BME280_Set_I2C_Pins.ino │ │ ├── ESP32_Multiple_I2C_Devices_Same_Bus_BME280_OLED.ino │ │ ├── ESP32_Two_Bus_interfaces.ino │ │ └── ESP32_Two_I2C_Bus_One_Default.ino │ ├── LILYGO_T-SIM7000G │ │ ├── Full_Test.ino │ │ ├── GPS_Tester.ino │ │ ├── HTTPS_GET_Request_Basic.ino │ │ ├── Network_Test.ino │ │ └── Send_Whatsapp_Message.ino │ ├── LoRaReceiver.ino │ ├── LoRaSender.ino │ ├── MicroSD_Card │ │ ├── ESP32_SD_Data_Logging.ino │ │ ├── ESP32_SD_Test.ino │ │ ├── ESP32_SD_Test_Pins.ino │ │ ├── ESP32_Web_Server_MicroSD_Card.ino │ │ └── files │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── index.zip │ │ │ ├── style.css │ │ │ └── style.zip │ ├── OTA_Web_Updater.ino │ ├── OTA_Web_Updater_LED.ino │ ├── Preferences │ │ ├── ESP32_Connect_WiFi_Preferences.ino │ │ ├── ESP32_Remember_Last_State.ino │ │ ├── ESP32_Save_Credentials.ino │ │ └── ESP32_StartCounter.ino │ ├── SPI │ │ ├── ESP32_BME280_Custom_SPI_Pins.ino │ │ └── ESP32_Find_SPI_Pins.ino │ ├── Set_Get_Time_DS1307_RTC.ino │ ├── Sync_Time_NTP_DS1307_RTC.ino │ ├── Sync_Time_NTP_DST_Timezone_DS1307_RTC.ino │ ├── Sync_Time_NTP_OLED_DS1307_RTC.ino │ ├── UART │ │ ├── UART0_Serial_Monitor.ino │ │ ├── UART_Receiver.ino │ │ └── UART_Sender.ino │ ├── VS_Code │ │ └── VS_Code_SPIFFS_Test.ino │ ├── detaLibTest.ino │ ├── dht22_web_server.ino │ └── web_server_outputs.ino ├── ESP32_Button_LED.ino ├── ESP32_ESP8266_BME280_Google_Sheets.ino ├── ESP8266-Bitcoin-Price │ └── bitcoinprice.lua ├── ESP8266-Communication │ ├── client.lua │ └── server.lua ├── ESP8266-HLK │ ├── ESP8266_Publish_MQTT_Message.ino │ └── NodeRED_Motion_Datalogger.txt ├── ESP8266-Serial-Communication-with-Arduino │ ├── Arduino_talks_with_ESP8266.ino │ └── init.lua ├── ESP8266-Web-Server │ └── init.lua ├── ESP8266 │ ├── AsyncElegantOTA │ │ ├── ESP8266_ElegantOTA_Demo │ │ │ └── ESP8266_ElegantOTA_Demo.ino │ │ ├── ESP8266_Web_Server_LED_OTA │ │ │ └── ESP8266_Web_Server_LED_OTA.ino │ │ └── ESP8266_Web_Server_OTA_SPIFFS │ │ │ ├── ESP8266_Web_Server_OTA_SPIFFS.ino │ │ │ ├── data.zip │ │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── BME280_Web_Server │ │ ├── ESP8266_BME280_Web_Server.ino │ │ └── table_with_css.html │ ├── BMP388 │ │ ├── ESP8266_BMP388_Web_Server.ino │ │ └── bmp3xx_simpletest_ESP8266.ino │ ├── DHT11_module.lua │ ├── ESP8266_Access_Point_AP.ino │ ├── ESP8266_Analog_Read_ADC0.ino │ ├── ESP8266_Anemometer_Wind_Sensor.ino │ ├── ESP8266_Auto_Reconnect.ino │ ├── ESP8266_BME280_Test.ino │ ├── ESP8266_BME680.ino │ ├── ESP8266_BME680_Web_Server.ino │ ├── ESP8266_Blink_Without_Delay.ino │ ├── ESP8266_Change_MAC_Address.ino │ ├── ESP8266_Charts_Multiple_Series.zip │ ├── ESP8266_Charts_Multiple_Series │ │ ├── ESP8266_Charts_Multiple_Series.ino │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP8266_DC_Motor.ino │ ├── ESP8266_DC_Motor_Web_Server │ │ ├── ESP8266_DC_Motor_Web_Server.ino │ │ ├── ESP8266_DC_Motor_Web_Server.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ └── style.css │ ├── ESP8266_DS3231_Set_Alarms.ino │ ├── ESP8266_DS3231_Set_Get_Time.ino │ ├── ESP8266_Date_Time.ino │ ├── ESP8266_Digital_Inputs_Outputs.ino │ ├── ESP8266_Email_Attachments │ │ ├── ESP8266_Email_Attachments.ino │ │ ├── ESP8266_Email_Attachments.zip │ │ └── data │ │ │ ├── image.png │ │ │ └── text_file.txt │ ├── ESP8266_Epoch_Unix_Time.ino │ ├── ESP8266_Filesystem_Example.ino │ ├── ESP8266_Fixed_Static_IP.ino │ ├── ESP8266_Gauges │ │ ├── ESP8266_Gauges.ino │ │ ├── ESP8266_Gauges.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP8266_Get_MAC_Address.ino │ ├── ESP8266_HC_SR04.ino │ ├── ESP8266_HC_SR04_OLED.ino │ ├── ESP8266_HTTPS │ │ ├── ESP8266_BasicHttpsClient_Certificate.ino │ │ ├── ESP8266_BasicHttpsClient_Fingerprint.ino │ │ └── ESP8266_BasicHttpsClient_without_Certificate.ino │ ├── ESP8266_Interrupts_Timers.ino │ ├── ESP8266_Load_Cell │ │ ├── ESP8266_Calibrate_Load_Cell.ino │ │ ├── ESP8266_Digital_Scale.ino │ │ └── ESP8266_Test_Load_Cell.ino │ ├── ESP8266_MQTT │ │ ├── ESP8266_BME280.ino │ │ ├── ESP8266_BME680.ino │ │ ├── ESP8266_DHT.ino │ │ └── ESP8266_DS18B20.ino │ ├── ESP8266_MQTT_Subscribe_Control_Outputs.ino │ ├── ESP8266_Multiple_Sliders_Web_Server │ │ ├── ESP8266_Multiple_Sliders_Web_Server.ino │ │ ├── ESP8266_Multiple_Sliders_Web_Server.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP8266_NEO_6M_GPS_TinyGPS.ino │ ├── ESP8266_NEO_M8N_GPS_TinyGPS.ino │ ├── ESP8266_Network_Events_CD.ino │ ├── ESP8266_PWM_Fade_LED.ino │ ├── ESP8266_Pushover_Notifications.ino │ ├── ESP8266_RCWL_0516_Basic.ino │ ├── ESP8266_RFID │ │ ├── RFID_Read_Raw_Data.ino │ │ ├── RFID_Read_UID.ino │ │ └── RFID_Write_Read_Personal_Data.ino │ ├── ESP8266_Reconnect_WiFi.ino │ ├── ESP8266_Relay_Control.ino │ ├── ESP8266_Relay_Module_Web_Server.ino │ ├── ESP8266_SPIFFS │ │ ├── ESP8266_SPIFFS.ino │ │ ├── ESP8266_SPIFFS.zip │ │ └── data │ │ │ ├── index.html │ │ │ └── style.css │ ├── ESP8266_Send_Messages_WhatsApp.ino │ ├── ESP8266_Sensor_Readings_WebSocket │ │ ├── ESP8266_Sensor_Readings_WebSocket.ino │ │ ├── ESP8266_Sensor_Readings_WebSocket.zip │ │ └── data │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP8266_Server_Sent_Events.ino │ ├── ESP8266_Set_Hostname.ino │ ├── ESP8266_Slider_PWM.ino │ ├── ESP8266_Stepper_Motor_Basic.ino │ ├── ESP8266_Stepper_Motor_Websocket │ │ ├── ESP8266_Stepper_Motor_Websocket.ino │ │ ├── ESP8266_Stepper_Motor_Websocket.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ ├── ESP8266_TDS_Sensor.ino │ ├── ESP8266_Telegram_Door.ino │ ├── ESP8266_Testing_LittleFS.ino │ ├── ESP8266_Thermocouple.ino │ ├── ESP8266_ThingSpeak_Multiple_Fields.ino │ ├── ESP8266_ThingSpeak_Single_Field.ino │ ├── ESP8266_WebSerial.ino │ ├── ESP8266_WebSocket_Server.ino │ ├── ESP8266_WiFi_DHT_Web_Server.ino │ ├── ESP8266_WiFi_Manager │ │ ├── ESP8266_WiFi_Manager.ino │ │ ├── ESP8266_WiFi_Manager.zip │ │ └── data │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── style.css │ │ │ └── wifimanager.html │ ├── ESP8266_WiFi_Web_Server_Color_Picker.ino │ ├── ESP8266_Write_File_LittleFS.ino │ ├── ESP8266_Write_File_LittleFS_Prevent_Overwrite.ino │ ├── ESPAsyncWebServer_library_example.ino │ ├── ESP_NOW │ │ ├── ESP_NOW_ESP8266_Web_Server_Receiver.ino │ │ ├── ESP_NOW_ESP8266_Web_Server_Sender.ino │ │ ├── ESP_NOW_Receiver.ino │ │ ├── ESP_NOW_Receiver_Many_to_One.ino │ │ ├── ESP_NOW_Receiver_One_to_Many.ino │ │ ├── ESP_NOW_Send_Different_Messages_One_to_Many.ino │ │ ├── ESP_NOW_Sender.ino │ │ ├── ESP_NOW_Sender_Many_to_One.ino │ │ ├── ESP_NOW_Sender_One_to_Many.ino │ │ └── ESP_NOW_Two_Way.ino │ ├── ElegantOTA │ │ ├── ESP8266_ElegantOTA_Basic.ino │ │ └── ESP8266_WebServer_LED_ElegantOTA.ino │ ├── HLK_PM03_ESP8266.ino │ ├── HTTP │ │ ├── ESP8266_HTTP_GET_JSON.ino │ │ ├── ESP8266_HTTP_GET_Open_Weather_Map.ino │ │ ├── ESP8266_HTTP_GET_Think_Speak.ino │ │ ├── ESP8266_HTTP_GET_Update.ino │ │ ├── ESP8266_HTTP_POST.ino │ │ ├── ESP8266_HTTP_POST_IFTTT.ino │ │ └── ESP8266_HTTP_POST_Think_Speak.ino │ ├── HTTPS_ESP8266_Send_Email_PHP.ino │ ├── Set_Get_Time_DS1307_RTC.ino │ ├── Sync_Time_NTP_DS1307_RTC.ino │ ├── Sync_Time_NTP_DST_Timezone_DS1307_RTC.ino │ ├── Sync_Time_NTP_OLED_DS1307_RTC.ino │ ├── VS_Code │ │ └── VS_Code_LittleFS_Test.ino │ ├── blink.lua │ ├── dht.lua │ ├── email_notifier_ifttt.lua │ ├── emaill_notifier.lua │ ├── maindht.lua │ ├── sensor_and_output.lua │ ├── web-server-authentication.lua │ └── web-server.lua ├── ESP8266_Controller.lua ├── ESP8266_Daily_Task.ino ├── ESP8266_NodeRED_MQTT_LED_DHT.ino ├── ESP8266_Oled_display.ino ├── ESP8266_RGB_Color_Picker.lua ├── ESP8266_RGB_Color_Picker_New.lua ├── ESP8266_Remote_Controlled_Outlet.ino ├── ESP8266_Web_Server_Arduino_IDE.ino ├── ESP8266_Web_Server_Arduino_IDE_updated.ino ├── ESP8266_WiFi_Button.ino ├── ESP8266_dht_arduino_ide.ino ├── ESPEasy │ └── Sonoff_and_Node_RED.txt ├── ESP_OTA_Arduino.ino ├── ESP_OTA_Arduino_Modified.ino ├── ESP_RGB_Color_Picker.lua ├── Fingerprint │ ├── Fingerprint_oled.ino │ ├── enroll.ino │ └── fingerprint_match.ino ├── GSM │ ├── makePhoneCall.ino │ ├── receiveCall.ino │ ├── receiveSMS.ino │ └── sendSMS.ino ├── HelloWorldPCD8544.ino ├── How_do_RGB_LEDs_work.ino ├── LCD_I2C │ ├── I2C_LCD_Display_Text.ino │ ├── I2C_LCD_Example.ino │ └── I2C_Scanner.ino ├── MFRC522_RFID_Reader_with_Arduino.ino ├── MIT-App-Inventor │ ├── Arduino_Bluetooth_DC_Motors.aia │ ├── Arduino_Bluetooth_DC_Motors.apk │ ├── Control_2_DC_Motors_Via_Bluetooth.ino │ ├── Control_RGB_LED.aia │ ├── Control_RGB_LED.apk │ └── Control_RGB_LED.ino ├── Magnetic_Contact_Switch.ino ├── Mood_Light_with_ESP8266.lua ├── Nextion_28_Project_Example │ ├── Nextion_28_Project.HMI │ ├── Nextion_28_Project.tft │ ├── Nextion_28_Project │ │ └── Nextion_28_Project.ino │ └── background_blue.png ├── Night_Security_Light_with_Arduino.ino ├── Node-RED_Neopixel_flow.txt ├── Node-RED_Yeelight_flow.txt ├── OLED │ ├── bitmap_array.c │ ├── oled_adafruit_demo.ino │ ├── oled_arduino_dht_temperature_humidity.ino │ ├── oled_arduino_display_bitmap.ino │ ├── oled_dht_temperature_humidity.ino │ ├── oled_display_bitmap.ino │ ├── oled_draw_shapes.ino │ ├── oled_hello_world.ino │ ├── oled_scroll_text.ino │ └── oled_set_different_fonts.ino ├── PiCamera │ ├── record_video.py │ └── take_photo.py ├── Post_Tweet_ESP8266.lua ├── Post_Tweet_ESP8266_Contains_Data.lua ├── Power_Latch_Circuit.ino ├── RPi-ESP-DHT │ ├── app.py │ ├── esp8266_dht.ino │ └── templates │ │ └── main.html ├── RPi-ESP-Outputs │ ├── app.py │ ├── esp8266_outputs.ino │ └── templates │ │ └── main.html ├── RPi-ESP-SQLite │ ├── app.py │ ├── esp8266_sqlite.ino │ └── templates │ │ └── main.html ├── RPi-Web-Server │ ├── app_outputs.py │ └── main_outputs.html ├── RPi_Keyboard_Example.py ├── Raspberry-Pi-Pico │ ├── Arduino │ │ ├── AnalogRead_Potentiometer.ino │ │ ├── AnalogWrite_Fade_LED.ino │ │ ├── Anemometer_Wind_Sensor.ino │ │ ├── BME280_Basic.ino │ │ ├── BME680_Basic.ino │ │ ├── Blink │ │ │ └── Blink.ino │ │ ├── DS18B20_Get_Sensor_Address.ino │ │ ├── DS18B20_Multiple_Sensors_Addresses.ino │ │ ├── DS18B20_Single.ino │ │ ├── I2C_Scanner.ino │ │ ├── Oled │ │ │ ├── Image.c │ │ │ ├── SSD1306_Oled_Basic.ino │ │ │ ├── SSD1306_Oled_Custom_Font.ino │ │ │ ├── SSD1306_Oled_Display_Bitmap_Images.ino │ │ │ └── SSD1306_Oled_Draw_Shapes.ino │ │ ├── PIR_Detect_Motion.ino │ │ ├── PIR_Detect_Motion_Interrupt.ino │ │ ├── Pico_Internal_Temperature_Sensor.ino │ │ ├── Pushbutton_LED_Inputs_Outputs.ino │ │ ├── RCWL_0516_Basic.ino │ │ └── Read_DHT_Sensor.ino │ └── MicroPython │ │ ├── Anemometer_Wind_Sensor.py │ │ ├── BH1750_Basic.py │ │ ├── BME680_Basic.py │ │ ├── Connect_to_Wi-Fi.py │ │ ├── Control_DC_Motor.py │ │ ├── Control_Servo_Motor_Module.py │ │ ├── Control_Servo_Motor_PWM.py │ │ ├── Control_Stepper_Motor.py │ │ ├── DS3231_Set_Alarms.py │ │ ├── DS3231_Set_Periodic_Alarms.py │ │ ├── DS3231_Sync_Time.py │ │ ├── HTTP_Request_Basic.py │ │ ├── HTTP_Request_Get_Bitcoin_Price.py │ │ ├── HTTP_Request_Get_Weather.py │ │ ├── I2C_Scanner.py │ │ ├── Internal_Temperature_Sensor_picozero.py │ │ ├── Internal_Temperature_Sensor_picozero_loop.py │ │ ├── LCD_Display_Custom_Characters.py │ │ ├── LCD_Scrolling_Text.py │ │ ├── LDC_Display_Static_Text.py │ │ ├── NEO_6M_GPS_Basic.py │ │ ├── NEO_6M_GPS_Raw_Data.py │ │ ├── NEO_M8N_GPS_Parsed_Data.py │ │ ├── NEO_M8N_GPS_Raw_Data.py │ │ ├── NEO_M8N_GPS_SD_Card_Logger.py │ │ ├── PIR_Detect_Motion.py │ │ ├── PIR_Detect_Motion_Interrupt.py │ │ ├── Pico_Asynchronous_Programming.py │ │ ├── Pico_Internal_Temperature_Sensor.py │ │ ├── Scan_Networks.py │ │ ├── Static_IP_Address.py │ │ ├── Station_Access_Point_Interfaces.py │ │ ├── Test_Micro_SD_Card.py │ │ ├── Whatsapp_callmebot.py │ │ ├── async_web_server.py │ │ ├── bh1750.py │ │ ├── bme680.py │ │ ├── dcmotor.py │ │ ├── email │ │ ├── Send_Email_Basic.py │ │ └── umail.py │ │ ├── flash_nuke.uf2 │ │ ├── get_time_rtc_module.py │ │ ├── interrupts │ │ ├── Blink_LED_Timer.py │ │ ├── Multiple_LEDs_Timer.py │ │ ├── PIR_Motion_Sensor.py │ │ ├── Pushbutton_Counter_LED.py │ │ ├── Pushbutton_Debounce.py │ │ ├── Pushbutton_Interrupt.py │ │ └── Pushbutton_Interrupt_Counter.py │ │ ├── lcd_api.py │ │ ├── main_Analog_Inputs_Potentiometer.py │ │ ├── main_BME280_Basic.py │ │ ├── main_Basic_Web_Server.py │ │ ├── main_DS18B20_Multiple_Sensors_Addresses.py │ │ ├── main_DS18B20_Single.py │ │ ├── main_PWM_Fade_LED.py │ │ ├── main_Pushbutton_LED_Inputs_Outputs.py │ │ ├── main_RCWL_0516_Basic.py │ │ ├── main_Read_DHT_Sensor.py │ │ ├── main_SSD1306_.Oled_Basic.py │ │ ├── micropyGPS.py │ │ ├── mqtt │ │ ├── config.py │ │ ├── mqtt_publish.py │ │ ├── mqtt_subscribe.py │ │ └── umqtt │ │ │ ├── robust.py │ │ │ └── simple.py │ │ ├── pico_i2c_lcd.py │ │ ├── sd_card │ │ ├── micro_sd_card_create_write_read.py │ │ ├── micro_sd_card_create_write_read_delete.py │ │ ├── sdcard.py │ │ ├── temperature_data_logger.py │ │ └── test_microsd_card.py │ │ ├── servo.py │ │ ├── stepper.py │ │ ├── sync_rtc_time.py │ │ └── urtc.py ├── Raspberry-Pi │ ├── OpenCV │ │ └── opencv_test_usb_camera.py │ ├── blinking_led.py │ ├── bme280_basic.py │ ├── bme280_data_logger.py │ ├── capture_video.py │ ├── control_outputs_based_on_time.py │ ├── control_outputs_based_on_time_conditions.py │ ├── dht_basic.py │ ├── dht_data_logger.py │ ├── ds18b20_basic.py │ ├── inputs │ │ ├── digital_input_device.py │ │ ├── digital_input_device_events.py │ │ ├── potentiometer_led.py │ │ ├── pushbutton_is_pressed.py │ │ ├── pushbutton_led.py │ │ └── toggle_when_pressed.py │ ├── led_blink.py │ ├── led_toggle.py │ ├── motion_detection_email_notifications.py │ ├── new_dht_basic.py │ ├── pir_motion_sensor.py │ ├── pwm │ │ ├── fade_led.py │ │ ├── fade_led_pulse.py │ │ ├── fade_pwm_output_device.py │ │ └── pulse_with_blink.py │ ├── send_email.py │ ├── stream_server.py │ └── take_photo.py ├── ReceiveDemo_Advanced.ino ├── SD_card_datalogger.c ├── SFE_BMP180_example.ino ├── SerialDebug │ ├── Example.ino │ └── SerialDebug_Example_dbg.ino ├── Sonoff_local_web_server.ino ├── TCA9548A │ ├── I2C_Multiplexer_Multiple_BME280.ino │ ├── I2C_Multiplexer_Multiple_OLED.ino │ └── I2C_Multiplexer_Multiple_OLED_instances.ino ├── Teensy_Arduino_Memory_Game.c ├── Teensy_Username_and_Password_Auto_Filler.c ├── Temperature_Displayed_on_4_Digit_7_segment_common_anode.c ├── Ultrasonic_Sensor_HC-SR04.c ├── Ultrasonic_Sensor_HC-SR04_with_NewPing.c ├── Ultrasonic_Sensor_with_LEDs_bar_graph_and_buzzer.c ├── WiFiManager │ ├── ESP8266_Web_Server_WiFiManager.ino │ └── ESP8266_Web_Server_WiFiManager_Custom_Parameter.ino ├── Yves-Arbour │ ├── counterMax.lua │ ├── ds18b20.lua │ ├── ds18b20_fahrenheit.lua │ ├── init_client.lua │ └── init_server.lua ├── arduino_ethernet_web_server.ino ├── blinkWithoutDelay.ino ├── blink_led_esp8266.ino ├── color │ ├── Color_Sensor_TCS230_TCS3200_1.ino │ └── Color_Sensor_TCS230_TCS3200_2.ino ├── color_picker.lua ├── decode-rf-arduino │ ├── ReceiveDemo_Advanced.ino │ └── SendDemoExample.ino ├── dht_temperature_serial_plotter.ino ├── display_tempreature_and_humidity_in_oled.ino ├── dot_matrix_faces.ino ├── dot_matrix_pong_game.ino ├── esp_print_adc.lua ├── node_red_flow_xiaomi_bedside_lamp.txt ├── nrf24_client.ino ├── nrf24_server.ino ├── rain_sensor_arduino.ino ├── rpi_camera_surveillance_system.py ├── rtc_example.ino ├── smoke_detector.ino ├── soil_moisture_sensor_arduino.ino └── tft │ ├── draw_shapes.ino │ └── write_text.ino └── README.md /Projects/433MHz/receiver.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include // Not actualy used but needed to compile 3 | 4 | RH_ASK driver; 5 | 6 | void setup() 7 | { 8 | Serial.begin(9600); // Debugging only 9 | if (!driver.init()) 10 | Serial.println("init failed"); 11 | } 12 | 13 | void loop() 14 | { 15 | uint8_t buf[12]; 16 | uint8_t buflen = sizeof(buf); 17 | if (driver.recv(buf, &buflen)) // Non-blocking 18 | { 19 | int i; 20 | // Message with a good checksum received, dump it. 21 | Serial.print("Message: "); 22 | Serial.println((char*)buf); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Projects/433MHz/transmitter.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include // Not actually used but needed to compile 3 | 4 | RH_ASK driver; 5 | 6 | void setup() 7 | { 8 | Serial.begin(9600); // Debugging only 9 | if (!driver.init()) 10 | Serial.println("init failed"); 11 | } 12 | 13 | void loop() 14 | { 15 | const char *msg = "Hello World!"; 16 | driver.send((uint8_t *)msg, strlen(msg)); 17 | driver.waitPacketSent(); 18 | delay(1000); 19 | } 20 | -------------------------------------------------------------------------------- /Projects/Arduino-GPS/GPS_Raw_Data.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | #include 7 | 8 | // The serial connection to the GPS module 9 | SoftwareSerial ss(4, 3); 10 | 11 | void setup(){ 12 | Serial.begin(9600); 13 | ss.begin(9600); 14 | } 15 | 16 | void loop(){ 17 | while (ss.available() > 0){ 18 | // get the byte data from the GPS 19 | byte gpsData = ss.read(); 20 | Serial.write(gpsData); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Projects/Arduino-GPS/NEO_6M_get_location.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | static const int RXPin = 4, TXPin = 3; 10 | static const uint32_t GPSBaud = 9600; 11 | 12 | // The TinyGPS++ object 13 | TinyGPSPlus gps; 14 | 15 | // The serial connection to the GPS device 16 | SoftwareSerial ss(RXPin, TXPin); 17 | 18 | void setup(){ 19 | Serial.begin(9600); 20 | ss.begin(GPSBaud); 21 | } 22 | 23 | void loop(){ 24 | // This sketch displays information every time a new sentence is correctly encoded. 25 | while (ss.available() > 0){ 26 | gps.encode(ss.read()); 27 | if (gps.location.isUpdated()){ 28 | Serial.print("Latitude= "); 29 | Serial.print(gps.location.lat(), 6); 30 | Serial.print(" Longitude= "); 31 | Serial.println(gps.location.lng(), 6); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Projects/Arduino/Arduino_LM35_LM335_LM34.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details https://RandomNerdTutorials.com 4 | */ 5 | 6 | const int sensorPin = A0; 7 | float sensorValue; 8 | float voltageOut; 9 | 10 | float temperatureC; 11 | float temperatureF; 12 | 13 | // uncomment if using LM335 14 | //float temperatureK; 15 | 16 | void setup() { 17 | pinMode(sensorPin, INPUT); 18 | Serial.begin(9600); 19 | } 20 | 21 | void loop() { 22 | sensorValue = analogRead(sensorPin); 23 | voltageOut = (sensorValue * 5000) / 1024; 24 | 25 | // calculate temperature for LM35 (LM35DZ) 26 | temperatureC = voltageOut / 10; 27 | temperatureF = (temperatureC * 1.8) + 32; 28 | 29 | // calculate temperature for LM335 30 | //temperatureK = voltageOut / 10; 31 | //temperatureC = temperatureK - 273; 32 | //temperatureF = (temperatureC * 1.8) + 32; 33 | 34 | // calculate temperature for LM34 35 | //temperatureF = voltageOut / 10; 36 | //temperatureC = (temperatureF - 32.0)*(5.0/9.0); 37 | 38 | Serial.print("Temperature(ºC): "); 39 | Serial.print(temperatureC); 40 | Serial.print(" Temperature(ºF): "); 41 | Serial.print(temperatureF); 42 | Serial.print(" Voltage(mV): "); 43 | Serial.println(voltageOut); 44 | delay(1000); 45 | } 46 | -------------------------------------------------------------------------------- /Projects/Arduino/Arduino_NEO_M8N_GPS_Raw_Data.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/arduino-neo-m8n-gps-module/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | 8 | #include 9 | 10 | static const int RXPin = 6, TXPin = 5; 11 | static const uint32_t GPSBaud = 9600; 12 | 13 | // The serial connection to the GPS module 14 | SoftwareSerial gpsSerial(RXPin, TXPin); 15 | 16 | void setup(){ 17 | Serial.begin(9600); 18 | gpsSerial.begin(GPSBaud); 19 | } 20 | 21 | void loop(){ 22 | while (gpsSerial.available() > 0){ 23 | // get the byte data from the GPS 24 | byte gpsData = gpsSerial.read(); 25 | Serial.write(gpsData); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Projects/Arduino/Arduino_Thermocouple.ino: -------------------------------------------------------------------------------- 1 | // this example is public domain. enjoy! https://learn.adafruit.com/thermocouple/ 2 | 3 | #include "max6675.h" 4 | 5 | int thermoDO = 4; 6 | int thermoCS = 5; 7 | int thermoCLK = 6; 8 | 9 | MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | 14 | Serial.println("MAX6675 test"); 15 | // wait for MAX chip to stabilize 16 | delay(500); 17 | } 18 | 19 | void loop() { 20 | // basic readout test, just print the current temp 21 | 22 | Serial.print("C = "); 23 | Serial.println(thermocouple.readCelsius()); 24 | Serial.print("F = "); 25 | Serial.println(thermocouple.readFahrenheit()); 26 | 27 | // For the MAX6675 to update, you must delay AT LEAST 250ms between reads! 28 | delay(1000); 29 | } 30 | -------------------------------------------------------------------------------- /Projects/Arduino/BH1750test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example of BH1750 library usage. This example initialises the BH1750 object using the default high resolution continuous mode and then makes a light level reading every second. 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | BH1750 lightMeter; 9 | 10 | void setup(){ 11 | Serial.begin(9600); 12 | 13 | // Initialize the I2C bus (BH1750 library doesn't do this automatically) 14 | Wire.begin(); 15 | // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3); 16 | // For Wemos / Lolin D1 Mini Pro and the Ambient Light shield use Wire.begin(D2, D1); 17 | 18 | lightMeter.begin(); 19 | 20 | Serial.println(F("BH1750 Test begin")); 21 | } 22 | 23 | void loop() { 24 | float lux = lightMeter.readLightLevel(); 25 | Serial.print("Light: "); 26 | Serial.print(lux); 27 | Serial.println(" lx"); 28 | delay(1000); 29 | } 30 | -------------------------------------------------------------------------------- /Projects/Arduino_Poor_mans_oscilloscope.c: -------------------------------------------------------------------------------- 1 | /* 2 | Complete project details: http://randomnerdtutorials.com/arduino-poor-mans-oscilloscope/ 3 | */ 4 | 5 | #define ANALOG_IN 0 6 | 7 | void setup() { 8 | Serial.begin(9600); 9 | //Serial.begin(115200); 10 | } 11 | 12 | void loop() { 13 | int val = analogRead(ANALOG_IN); 14 | Serial.write( 0xff ); 15 | Serial.write( (val >> 8) & 0xff ); 16 | Serial.write( val & 0xff ); 17 | } 18 | -------------------------------------------------------------------------------- /Projects/Arduino_microphone_sensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | int ledPin=13; 7 | int sensorPin=7; 8 | boolean val =0; 9 | 10 | void setup(){ 11 | pinMode(ledPin, OUTPUT); 12 | pinMode(sensorPin, INPUT); 13 | Serial.begin (9600); 14 | } 15 | 16 | void loop (){ 17 | val =digitalRead(sensorPin); 18 | Serial.println (val); 19 | // when the sensor detects a signal above the threshold value, LED flashes 20 | if (val==HIGH) { 21 | digitalWrite(ledPin, HIGH); 22 | } 23 | else { 24 | digitalWrite(ledPin, LOW); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Projects/Arduino_tilt_sensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | 7 | int ledPin = 12; 8 | int sensorPin = 4; 9 | int sensorValue; 10 | int lastTiltState = HIGH; // the previous reading from the tilt sensor 11 | 12 | // the following variables are long's because the time, measured in miliseconds, 13 | // will quickly become a bigger number than can be stored in an int. 14 | long lastDebounceTime = 0; // the last time the output pin was toggled 15 | long debounceDelay = 50; // the debounce time; increase if the output flickers 16 | 17 | void setup(){ 18 | pinMode(sensorPin, INPUT); 19 | digitalWrite(sensorPin, HIGH); 20 | pinMode(ledPin, OUTPUT); 21 | Serial.begin(9600); 22 | } 23 | 24 | void loop(){ 25 | sensorValue = digitalRead(sensorPin); 26 | // If the switch changed, due to noise or pressing: 27 | if (sensorValue == lastTiltState) { 28 | // reset the debouncing timer 29 | lastDebounceTime = millis(); 30 | } 31 | if ((millis() - lastDebounceTime) > debounceDelay) { 32 | // whatever the reading is at, it's been there for longer 33 | // than the debounce delay, so take it as the actual current state: 34 | lastTiltState = sensorValue; 35 | } 36 | digitalWrite(ledPin, lastTiltState); 37 | 38 | Serial.println(sensorValue); 39 | delay(500); 40 | } 41 | -------------------------------------------------------------------------------- /Projects/Arduino_with_Keypad.ino: -------------------------------------------------------------------------------- 1 | #include "Keypad.h" 2 | 3 | const byte ROWS = 4; // number of rows 4 | const byte COLS = 3; // number of columns 5 | char keys[ROWS][COLS] = { 6 | {'1','2','3'}, 7 | {'4','5','6'}, 8 | {'7','8','9'}, 9 | {'#','0','*'} 10 | }; 11 | 12 | byte rowPins[ROWS] = {8, 7, 6, 5}; // row pinouts of the keypad R1 = D8, R2 = D7, R3 = D6, R4 = D5 13 | byte colPins[COLS] = {4, 3, 2}; // column pinouts of the keypad C1 = D4, C2 = D3, C3 = D2 14 | Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); 15 | 16 | void setup() 17 | { 18 | Serial.begin(9600); 19 | } 20 | 21 | void loop() 22 | { 23 | char key = keypad.getKey(); 24 | if (key != NO_KEY) 25 | Serial.println(key); 26 | } 27 | -------------------------------------------------------------------------------- /Projects/BeagleBone/BBB-BoneScript-Web-Server/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Home Automation Web Server with BeagleBone 5 | 6 | 26 | 27 |

LED

28 |

Status

29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Projects/BeagleBone/BBB-Surveillance-Python/surveillance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | #import libraries 4 | import smtplib 5 | 6 | import Adafruit_BBIO.GPIO as GPIO 7 | import time 8 | 9 | #create a variable called PIR, which refers to the P8_11 pin 10 | PIR = "P8_11" 11 | 12 | #initialize the pin as an INPUT 13 | GPIO.setup(PIR, GPIO.IN) 14 | GPIO.add_event_detect(PIR, GPIO.RISING) 15 | 16 | def send_email(): 17 | server = smtplib.SMTP('smtp.gmail.com', 587) 18 | server.ehlo() 19 | server.starttls() 20 | server.ehlo() 21 | my_email = "REPLACE_WITH_YOUR_EMAIL@gmail.com" 22 | my_password = "REPLACE_WITH_YOUR_PASSWORD" 23 | destination = "REPLACE_WITH_YOUR_EMAIL@gmail.com" 24 | text = "Motion has been detected at your house!" 25 | 26 | server.login(my_email, my_password) 27 | server.sendmail(my_email, destination, text) 28 | server.quit() 29 | print("Your email has been sent!") 30 | 31 | #loop forever 32 | while True: 33 | #sends an email when motion has been detected 34 | if GPIO.event_detected(PIR): 35 | send_email() 36 | time.sleep(0.05) #loop every 50 miliseconds to not overburden the CPU 37 | -------------------------------------------------------------------------------- /Projects/Control_Servo_with_Visual_Basic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Control a servo motor with Visual Basic 3 | * Created by Rui Santos, http://randomnerdtutorials.com 4 | */ 5 | 6 | #include 7 | 8 | Servo myservo; // create servo object to control a servo 9 | 10 | void setup() 11 | { 12 | myservo.attach(9); // attaches the servo on pin 9 to the servo object 13 | Serial.begin(9600); //begins serial communication 14 | } 15 | 16 | void loop() 17 | { 18 | int pos; 19 | if (Serial.available()){ 20 | delay(100); 21 | while(Serial.available()>0){ 22 | pos=Serial.read(); //reads the value sent from Visual Basic 23 | if(pos=='0') 24 | myservo.write(90); //rotates the servo 90 degrees (Left) 25 | else if(pos=='1') 26 | myservo.write(-90); //rotates the servo 90 degrees (right) 27 | else if(pos=='2') 28 | myservo.write(180); //rotates the servo 180 degrees (Left) 29 | else if(pos=='3') 30 | myservo.write(-180); //rotates the servo 180 degrees (right) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Projects/DS18B20_Temperature_Sensor_Arduino.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at http://randomnerdtutorials.com 4 | Based on the Dallas Temperature Library example 5 | *********/ 6 | 7 | #include 8 | #include 9 | 10 | // Data wire is conntec to the Arduino digital pin 4 11 | #define ONE_WIRE_BUS 4 12 | 13 | // Setup a oneWire instance to communicate with any OneWire devices 14 | OneWire oneWire(ONE_WIRE_BUS); 15 | 16 | // Pass our oneWire reference to Dallas Temperature sensor 17 | DallasTemperature sensors(&oneWire); 18 | 19 | void setup(void) 20 | { 21 | // Start serial communication for debugging purposes 22 | Serial.begin(9600); 23 | // Start up the library 24 | sensors.begin(); 25 | } 26 | 27 | void loop(void){ 28 | // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus 29 | sensors.requestTemperatures(); 30 | 31 | Serial.print("Celsius temperature: "); 32 | // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire 33 | Serial.print(sensors.getTempCByIndex(0)); 34 | Serial.print(" - Fahrenheit temperature: "); 35 | Serial.println(sensors.getTempFByIndex(0)); 36 | delay(1000); 37 | } 38 | -------------------------------------------------------------------------------- /Projects/DeepSleep/deep_sleep_esp01.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ESP8266 Deep sleep mode example 3 | * Rui Santos 4 | * Complete Project Details http://randomnerdtutorials.com 5 | */ 6 | 7 | void setup() { 8 | Serial.begin(115200); 9 | Serial.setTimeout(2000); 10 | 11 | // Wait for serial to initialize. 12 | while(!Serial) { } 13 | 14 | // Deep sleep mode for 30 seconds, the ESP8266 wakes up by itself when GPIO 16 (D0 in NodeMCU board) is connected to the RESET pin 15 | //Serial.println("I'm awake, but I'm going into deep sleep mode for 30 seconds"); 16 | //ESP.deepSleep(30e6); 17 | 18 | // Deep sleep mode until RESET pin is connected to a LOW signal (for example pushbutton or magnetic reed switch) 19 | Serial.println("I'm awake, but I'm going into deep sleep mode until RESET pin is connected to a LOW signal"); 20 | ESP.deepSleep(0); 21 | } 22 | 23 | void loop() { 24 | } 25 | -------------------------------------------------------------------------------- /Projects/DeepSleep/deep_sleep_esp12E.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ESP8266 Deep sleep mode example 3 | * Rui Santos 4 | * Complete Project Details http://randomnerdtutorials.com 5 | */ 6 | 7 | void setup() { 8 | Serial.begin(115200); 9 | Serial.setTimeout(2000); 10 | 11 | // Wait for serial to initialize. 12 | while(!Serial) { } 13 | 14 | // Deep sleep mode for 30 seconds, the ESP8266 wakes up by itself when GPIO 16 (D0 in NodeMCU board) is connected to the RESET pin 15 | Serial.println("I'm awake, but I'm going into deep sleep mode for 30 seconds"); 16 | ESP.deepSleep(30e6); 17 | 18 | // Deep sleep mode until RESET pin is connected to a LOW signal (for example pushbutton or magnetic reed switch) 19 | //Serial.println("I'm awake, but I'm going into deep sleep mode until RESET pin is connected to a LOW signal"); 20 | //ESP.deepSleep(0); 21 | } 22 | 23 | void loop() { 24 | } 25 | -------------------------------------------------------------------------------- /Projects/ESP-IDF/hello_world/blink_led.c: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | https://RandomNerdTutorials.com/esp-idf-esp32-blink-led/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | 8 | #include 9 | #include "freertos/FreeRTOS.h" 10 | #include "freertos/task.h" 11 | #include "driver/gpio.h" 12 | #include "sdkconfig.h" 13 | 14 | // Define the GPIO pin for the LED (GPIO 2 is common for onboard LEDs) 15 | #define BLINK_GPIO 2 16 | 17 | void app_main(void) 18 | { 19 | // Configure the GPIO pin 20 | gpio_reset_pin(BLINK_GPIO); 21 | gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT); 22 | 23 | // Blink loop 24 | while (1) { 25 | // Turn LED ON 26 | printf("LED ON\n"); 27 | gpio_set_level(BLINK_GPIO, 1); 28 | vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay 1 second 29 | 30 | // Turn LED OFF 31 | printf("LED OFF\n"); 32 | gpio_set_level(BLINK_GPIO, 0); 33 | vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay 1 second 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/ESP32_ESP8266_Interact_GPIOs.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | # Created by Rui Santos 3 | 4 | from machine import Pin, ADC, PWM 5 | from time import sleep 6 | 7 | led = Pin(2, Pin.OUT) 8 | button = Pin(15, Pin.IN) 9 | 10 | #Configure ADC for ESP32 11 | pot = ADC(Pin(34)) 12 | pot.width(ADC.WIDTH_10BIT) 13 | pot.atten(ADC.ATTN_11DB) 14 | 15 | #Configure ADC for ESP8266 16 | #pot = ADC(0) 17 | 18 | led_pwm = PWM(Pin(4),5000) 19 | 20 | while True: 21 | button_state = button.value() 22 | led.value(button_state) 23 | 24 | pot_value = pot.read() 25 | led_pwm.duty(pot_value) 26 | 27 | sleep(0.1) 28 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/ESP32_Read_GPS_Data.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/micropython-esp32-neo-6m-gps/ 3 | 4 | import machine 5 | from time import sleep 6 | from micropyGPS import MicropyGPS 7 | 8 | # Instantiate the micropyGPS object 9 | my_gps = MicropyGPS() 10 | 11 | # Define the UART pins and create a UART object 12 | gps_serial = machine.UART(2, baudrate=9600, tx=17, rx=16) 13 | 14 | while True: 15 | try: 16 | while gps_serial.any(): 17 | data = gps_serial.read() 18 | for byte in data: 19 | stat = my_gps.update(chr(byte)) 20 | if stat is not None: 21 | # Print parsed GPS data 22 | print('UTC Timestamp:', my_gps.timestamp) 23 | print('Date:', my_gps.date_string('long')) 24 | print('Latitude:', my_gps.latitude_string()) 25 | print('Longitude:', my_gps.longitude_string()) 26 | print('Altitude:', my_gps.altitude) 27 | print('Satellites in use:', my_gps.satellites_in_use) 28 | print('Horizontal Dilution of Precision:', my_gps.hdop) 29 | print() 30 | 31 | except Exception as e: 32 | print(f"An error occurred: {e}") 33 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/ESP32_Read_Raw_GPS_Data.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/micropython-esp32-neo-6m-gps/ 3 | 4 | import machine 5 | from time import sleep 6 | 7 | # Define the UART pins and create a UART object 8 | gps_serial = machine.UART(2, baudrate=9600, tx=17, rx=16) 9 | 10 | while True: 11 | if gps_serial.any(): 12 | line = gps_serial.readline() # Read a complete line from the UART 13 | if line: 14 | line = line.decode('utf-8') 15 | print(line.strip()) 16 | sleep(0.5) 17 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/HCSR04/main_basic.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/ 2 | from hcsr04 import HCSR04 3 | from time import sleep 4 | 5 | # ESP32 6 | sensor = HCSR04(trigger_pin=5, echo_pin=18, echo_timeout_us=10000) 7 | 8 | # ESP8266 9 | #sensor = HCSR04(trigger_pin=12, echo_pin=14, echo_timeout_us=10000) 10 | 11 | while True: 12 | distance = sensor.distance_cm() 13 | print('Distance:', distance, 'cm') 14 | sleep(1) 15 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/HCSR04/main_oled.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/ 2 | from machine import Pin, I2C 3 | import ssd1306 4 | from hcsr04 import HCSR04 5 | from time import sleep 6 | 7 | # ESP32 Pin assignment 8 | i2c = I2C(scl=Pin(22), sda=Pin(21)) 9 | sensor = HCSR04(trigger_pin=5, echo_pin=18, echo_timeout_us=10000) 10 | 11 | # ESP8266 Pin assignment 12 | #i2c = I2C(scl=Pin(5), sda=Pin(4)) 13 | #sensor = HCSR04(trigger_pin=12, echo_pin=14, echo_timeout_us=10000) 14 | 15 | oled_width = 128 16 | oled_height = 64 17 | oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) 18 | 19 | while True: 20 | oled.fill(0) 21 | #oled.show() 22 | distance = sensor.distance_mm() 23 | print('Distance:', distance, 'mm') 24 | oled.text("Distance (mm)", 0, 15) 25 | oled.text(str(distance), 0, 35) 26 | oled.show() 27 | sleep(1) -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/OTA_Updates_PHP/boot.py: -------------------------------------------------------------------------------- 1 | # OTA updater for ESP32 running Micropython by David Flory 2 | # Tutorial: https://randomnerdtutorials.com/esp32-esp8266-micropython-ota-updates/ 3 | 4 | try: 5 | import usocket as socket 6 | except: 7 | import socket 8 | 9 | try: 10 | import urequests as requests 11 | except: 12 | import requests 13 | import os 14 | import sys 15 | import esp 16 | esp.osdebug(None) 17 | import gc 18 | gc.collect() 19 | from utime import sleep 20 | from utime import sleep_ms 21 | import network 22 | 23 | OTA = 0 -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/dcmotor.py: -------------------------------------------------------------------------------- 1 | # Created by https://RandomNerdTutorials.com/micropython-esp32-esp8266-dc-motor-l298n/ 2 | #This file includes a class to control DC motors 3 | 4 | class DCMotor: 5 | #the min_duty and max_duty are defined for 15000Hz frequency 6 | #you can pass as arguments 7 | def __init__(self, pin1, pin2, enable_pin, min_duty=750, max_duty=1023): 8 | self.pin1 = pin1 9 | self.pin2= pin2 10 | self.enable_pin = enable_pin 11 | self.min_duty = min_duty 12 | self.max_duty = max_duty 13 | 14 | #speed value can be between 0 and 100 15 | def forward(self, speed): 16 | self.speed = speed 17 | self.enable_pin.duty(self.duty_cycle(self.speed)) 18 | self.pin1.value(1) 19 | self.pin2.value(0) 20 | 21 | def backwards(self, speed): 22 | self.speed = speed 23 | self.enable_pin.duty(self.duty_cycle(self.speed)) 24 | self.pin1.value(0) 25 | self.pin2.value(1) 26 | 27 | def stop(self): 28 | self.enable_pin.duty(0) 29 | self.pin1.value(0) 30 | self.pin2.value(0) 31 | 32 | def duty_cycle(self, speed): 33 | if self.speed <= 0 or self.speed > 100: 34 | duty_cycle = 0 35 | else: 36 | duty_cycle = int (self.min_duty + (self.max_duty - self.min_duty)*((self.speed - 1)/(100-1))) 37 | return duty_cycle -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp32_esp8266_ws2812b_individual.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | import machine, neopixel 4 | 5 | n = 48 6 | p = 5 7 | 8 | np = neopixel.NeoPixel(machine.Pin(p), n) 9 | 10 | np[0] = (255, 0, 0) 11 | np[3] = (125, 204, 223) 12 | np[7] = (120, 153, 23) 13 | np[10] = (255, 0, 153) 14 | np.write() 15 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp32_lolin32_ssd1306_oled.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | from machine import Pin, SoftI2C 4 | import ssd1306 5 | from time import sleep 6 | 7 | # Start I2C Communication SCL = 4 and SDA = 5 on Wemos Lolin32 ESP32 with built-in SSD1306 OLED 8 | i2c = SoftI2C(scl=Pin(4), sda=Pin(5)) 9 | 10 | oled_width = 128 11 | oled_height = 64 12 | oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) 13 | 14 | oled.text('Hello, World 1!', 0, 0) 15 | oled.text('Hello, World 2!', 0, 10) 16 | oled.text('Hello, World 3!', 0, 20) 17 | 18 | oled.show() 19 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_access_point_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | import network 9 | 10 | import esp 11 | esp.osdebug(None) 12 | 13 | import gc 14 | gc.collect() 15 | 16 | ssid = 'MicroPython-AP' 17 | password = '123456789' 18 | 19 | ap = network.WLAN(network.AP_IF) 20 | ap.active(True) 21 | ap.config(essid=ssid, password=password) 22 | 23 | while ap.active() == False: 24 | pass 25 | 26 | print('Connection successful') 27 | print(ap.ifconfig()) 28 | 29 | def web_page(): 30 | html = """ 31 |

Hello, World!

""" 32 | return html 33 | 34 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 35 | s.bind(('', 80)) 36 | s.listen(5) 37 | 38 | while True: 39 | conn, addr = s.accept() 40 | print('Got a connection from %s' % str(addr)) 41 | request = conn.recv(1024) 42 | print('Content = %s' % str(request)) 43 | response = web_page() 44 | conn.send(response) 45 | conn.close() 46 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_asynchronous_programming.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/micropython-esp32-esp8266-asynchronous-programming/ 3 | 4 | import asyncio 5 | from machine import Pin 6 | 7 | green_led_pin = 14 8 | green_led = Pin(green_led_pin, Pin.OUT) 9 | blue_led_pin = 12 10 | blue_led = Pin(blue_led_pin, Pin.OUT) 11 | 12 | # Define coroutine function 13 | async def blink_green_led(): 14 | while True: 15 | green_led.value(not green_led.value() ) 16 | await asyncio.sleep(2) 17 | 18 | # Define coroutine function 19 | async def blink_blue_led(): 20 | while True: 21 | blue_led.value(not blue_led.value()) 22 | await asyncio.sleep(0.5) 23 | 24 | # Define the main function to run the event loop 25 | async def main(): 26 | # Create tasks for blinking two LEDs concurrently 27 | asyncio.create_task(blink_green_led()) 28 | asyncio.create_task(blink_blue_led()) 29 | 30 | # Create and run the event loop 31 | loop = asyncio.get_event_loop() 32 | loop.create_task(main()) # Create a task to run the main function 33 | loop.run_forever() # Run the event loop indefinitely 34 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_bh1750_test.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/micropython-bh1750-esp32-esp8266/ 3 | 4 | from machine import Pin, SoftI2C 5 | from bh1750 import BH1750 6 | import time 7 | 8 | # Initialize I2C communication (ESP32) 9 | i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=400000) 10 | 11 | 12 | # Initialize I2C communication (ESP8266) 13 | #i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=400000) 14 | 15 | # Create BH1750 object 16 | light_sensor = BH1750(bus=i2c, addr=0x23) 17 | 18 | try: 19 | # Read lux every 2 seconds 20 | while True: 21 | lux = light_sensor.luminance(BH1750.CONT_HIRES_1) 22 | print("Luminance: {:.2f} lux".format(lux)) 23 | time.sleep(2) 24 | 25 | except Exception as e: 26 | # Handle any exceptions during sensor reading 27 | print("An error occurred:", e) 28 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_blink_led_timer.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/micropython-timer-interrupts-ep32-esp8266/ 3 | 4 | from machine import Pin, Timer 5 | from time import sleep 6 | 7 | # LED pin 8 | led_pin = 13 9 | led = Pin(led_pin, Pin.OUT) 10 | 11 | # Callback function for the timer 12 | def toggle_led(timer): 13 | led.value(not led.value()) # Toggle the LED state (ON/OFF) 14 | 15 | # Create a periodic timer 16 | blink_timer = Timer(1) 17 | blink_timer.init(mode=Timer.PERIODIC, period=500, callback=toggle_led) # Timer repeats every half second 18 | 19 | try: 20 | # Main loop (optional) 21 | while True: 22 | print('Main Loop is running') 23 | sleep(2) 24 | except KeyboardInterrupt: 25 | # Keyboard interrupt occurred, deinitialize the timer 26 | blink_timer.deinit() 27 | print('Timer deinitialized') 28 | # Turn off the LED 29 | led.value(0) 30 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_blink_relay.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | from machine import Pin 4 | from time import sleep 5 | 6 | # ESP32 GPIO 26 7 | relay = Pin(26, Pin.OUT) 8 | 9 | # ESP8266 GPIO 5 10 | #relay = Pin(5, Pin.OUT) 11 | 12 | while True: 13 | # RELAY ON 14 | relay.value(0) 15 | sleep(10) 16 | # RELAY OFF 17 | relay.value(1) 18 | sleep(10) 19 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_bme280_readings.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | from machine import Pin, I2C 4 | from time import sleep 5 | import BME280 6 | 7 | # ESP32 - Pin assignment 8 | i2c = I2C(scl=Pin(22), sda=Pin(21), freq=10000) 9 | # ESP8266 - Pin assignment 10 | #i2c = I2C(scl=Pin(5), sda=Pin(4), freq=10000) 11 | 12 | while True: 13 | bme = BME280.BME280(i2c=i2c) 14 | temp = bme.temperature 15 | hum = bme.humidity 16 | pres = bme.pressure 17 | # uncomment for temperature in Fahrenheit 18 | #temp = (bme.read_temperature()/100) * (9/5) + 32 19 | #temp = str(round(temp, 2)) + 'F' 20 | print('Temperature: ', temp) 21 | print('Humidity: ', hum) 22 | print('Pressure: ', pres) 23 | 24 | sleep(5) 25 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_bme280_web_server_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | from time import sleep 9 | 10 | from machine import Pin, I2C 11 | import network 12 | 13 | import esp 14 | esp.osdebug(None) 15 | 16 | import gc 17 | gc.collect() 18 | 19 | import BME280 20 | 21 | # ESP32 - Pin assignment 22 | i2c = I2C(scl=Pin(22), sda=Pin(21), freq=10000) 23 | # ESP8266 - Pin assignment 24 | #i2c = I2C(scl=Pin(5), sda=Pin(4), freq=10000) 25 | 26 | ssid = 'REPLACE_WITH_YOUR_SSID' 27 | password = 'REPLACE_WITH_YOUR_PASSWORD' 28 | 29 | station = network.WLAN(network.STA_IF) 30 | 31 | station.active(True) 32 | station.connect(ssid, password) 33 | 34 | while station.isconnected() == False: 35 | pass 36 | 37 | print('Connection successful') 38 | print(station.ifconfig()) 39 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_bme680.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/micropython-bme680-esp32-esp8266/ 2 | 3 | from machine import Pin, I2C 4 | from time import sleep 5 | from bme680 import * 6 | 7 | # ESP32 - Pin assignment 8 | i2c = I2C(scl=Pin(22), sda=Pin(21)) 9 | # ESP8266 - Pin assignment 10 | #i2c = I2C(scl=Pin(5), sda=Pin(4)) 11 | 12 | bme = BME680_I2C(i2c=i2c) 13 | 14 | while True: 15 | try: 16 | temp = str(round(bme.temperature, 2)) + ' C' 17 | #temp = (bme.temperature) * (9/5) + 32 18 | #temp = str(round(temp, 2)) + 'F' 19 | 20 | hum = str(round(bme.humidity, 2)) + ' %' 21 | 22 | pres = str(round(bme.pressure, 2)) + ' hPa' 23 | 24 | gas = str(round(bme.gas/1000, 2)) + ' KOhms' 25 | 26 | print('Temperature:', temp) 27 | print('Humidity:', hum) 28 | print('Pressure:', pres) 29 | print('Gas:', gas) 30 | print('-------') 31 | except OSError as e: 32 | print('Failed to read sensor.') 33 | 34 | sleep(5) 35 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_bme680_web_server_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/micropython-bme680-esp32-esp8266/ 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | from time import sleep 9 | 10 | from machine import Pin, I2C 11 | import network 12 | 13 | import esp 14 | esp.osdebug(None) 15 | 16 | import gc 17 | gc.collect() 18 | 19 | from bme680 import * 20 | 21 | # ESP32 - Pin assignment 22 | i2c = I2C(scl=Pin(22), sda=Pin(21)) 23 | # ESP8266 - Pin assignment 24 | #i2c = I2C(scl=Pin(5), sda=Pin(4)) 25 | 26 | ssid = 'REPLACE_WITH_YOUR_SSID' 27 | password = 'REPLACE_WITH_YOUR_PASSWORD' 28 | 29 | station = network.WLAN(network.STA_IF) 30 | 31 | station.active(True) 32 | station.connect(ssid, password) 33 | 34 | while station.isconnected() == False: 35 | pass 36 | 37 | print('Connection successful') 38 | print(station.ifconfig()) 39 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_dcmotor.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/micropython-esp32-esp8266-dc-motor-l298n/ 2 | 3 | from dcmotor import DCMotor 4 | from machine import Pin, PWM 5 | from time import sleep 6 | 7 | frequency = 15000 8 | 9 | pin1 = Pin(12, Pin.OUT) 10 | pin2 = Pin(14, Pin.OUT) 11 | enable = PWM(Pin(13), frequency) 12 | 13 | dc_motor = DCMotor(pin1, pin2, enable) 14 | #Set min duty cycle (350) and max duty cycle (1023) 15 | #dc_motor = DCMotor(pin1, pin2, enable, 350, 1023) 16 | 17 | dc_motor.forward(50) 18 | sleep(2) 19 | dc_motor.stop() 20 | sleep(3) 21 | dc_motor.backwards(100) 22 | sleep(2) 23 | dc_motor.forward(5) 24 | sleep(5) 25 | dc_motor.stop() -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_dht_test.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | from machine import Pin 4 | from time import sleep 5 | import dht 6 | 7 | sensor = dht.DHT22(Pin(14)) 8 | #sensor = dht.DHT11(Pin(14)) 9 | 10 | while True: 11 | try: 12 | sleep(2) 13 | sensor.measure() 14 | temp = sensor.temperature() 15 | hum = sensor.humidity() 16 | temp_f = temp * (9/5) + 32.0 17 | print('Temperature: %3.1f C' %temp) 18 | print('Temperature: %3.1f F' %temp_f) 19 | print('Humidity: %3.1f %%' %hum) 20 | except OSError as e: 21 | print('Failed to read sensor.') 22 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_dht_web_server_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | import network 9 | from machine import Pin 10 | import dht 11 | 12 | import esp 13 | esp.osdebug(None) 14 | 15 | import gc 16 | gc.collect() 17 | 18 | ssid = 'REPLACE_WITH_YOUR_SSID' 19 | password = 'REPLACE_WITH_YOUR_PASSWORD' 20 | 21 | station = network.WLAN(network.STA_IF) 22 | 23 | station.active(True) 24 | station.connect(ssid, password) 25 | 26 | while station.isconnected() == False: 27 | pass 28 | 29 | print('Connection successful') 30 | print(station.ifconfig()) 31 | 32 | sensor = dht.DHT22(Pin(14)) 33 | #sensor = dht.DHT11(Pin(14)) 34 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_ds18b20.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | import machine, onewire, ds18x20, time 4 | 5 | ds_pin = machine.Pin(4) 6 | ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin)) 7 | 8 | roms = ds_sensor.scan() 9 | print('Found DS devices: ', roms) 10 | 11 | while True: 12 | ds_sensor.convert_temp() 13 | time.sleep_ms(750) 14 | for rom in roms: 15 | print(rom) 16 | print(ds_sensor.read_temp(rom)) 17 | time.sleep(5) 18 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_ds18b20_web_server_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | from time import sleep 9 | from machine import Pin 10 | import onewire, ds18x20 11 | 12 | import network 13 | 14 | import esp 15 | esp.osdebug(None) 16 | 17 | import gc 18 | gc.collect() 19 | 20 | ds_pin = Pin(4) 21 | ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin)) 22 | 23 | ssid = 'REPLACE_WITH_YOUR_SSID' 24 | password = 'REPLACE_WITH_YOUR_PASSWORD' 25 | 26 | station = network.WLAN(network.STA_IF) 27 | 28 | station.active(True) 29 | station.connect(ssid, password) 30 | 31 | while station.isconnected() == False: 32 | pass 33 | 34 | print('Connection successful') 35 | print(station.ifconfig()) 36 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_rcwl_0516_main.py: -------------------------------------------------------------------------------- 1 | # Complete project details: https://RandomNerdTutorials.com/micropython-rcwl-0516-esp32-esp8266/ 2 | 3 | from machine import Pin 4 | import time 5 | 6 | # Pin numbers for LED and sensor 7 | led_pin = 2 8 | sensor_pin = 12 9 | 10 | # Set the LED pin as an output and the sensor pin as an input 11 | led = Pin(led_pin, Pin.OUT) 12 | sensor = Pin(sensor_pin, Pin.IN) 13 | 14 | # Initialize state variables 15 | state = 0 16 | val = 0 17 | 18 | while True: 19 | val = sensor.value() # read sensor value 20 | 21 | if val == 1: # check if the sensor is HIGH 22 | led.on() # turn LED ON 23 | 24 | if state == 0: 25 | print("Motion detected!") 26 | state = 1 # update variable state to HIGH 27 | else: 28 | led.off() # turn LED OFF 29 | 30 | if state == 1: 31 | print("Motion stopped!") 32 | state = 0 # update variable state to LOW 33 | 34 | # Add a small delay to avoid constant checking of the sensor 35 | time.sleep(0.1) 36 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_relay_web_server_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | from machine import Pin 9 | import network 10 | 11 | import esp 12 | esp.osdebug(None) 13 | 14 | import gc 15 | gc.collect() 16 | 17 | ssid = 'REPLACE_WITH_YOUR_SSID' 18 | password = 'REPLACE_WITH_YOUR_PASSWORD' 19 | 20 | station = network.WLAN(network.STA_IF) 21 | 22 | station.active(True) 23 | station.connect(ssid, password) 24 | 25 | while station.isconnected() == False: 26 | pass 27 | 28 | print('Connection successful') 29 | print(station.ifconfig()) 30 | 31 | # ESP32 GPIO 26 32 | relay = Pin(26, Pin.OUT) 33 | 34 | # ESP8266 GPIO 5 35 | #relay = Pin(5, Pin.OUT) 36 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_send_email_smtp.py: -------------------------------------------------------------------------------- 1 | # Complete project details: https://RandomNerdTutorials.com/micropython-send-emails-esp32-esp826/ 2 | # Micropython lib to send emails: https://github.com/shawwwn/uMail 3 | import umail 4 | import network 5 | 6 | # Your network credentials 7 | ssid = 'REPLACE_WITH_YOUR_SSID' 8 | password = 'REPLACE_WITH_YOUR_PASSWORD' 9 | 10 | # Email details 11 | sender_email = 'REPLACE_WITH_THE_SENDER_EMAIL' 12 | sender_name = 'ESP32' #sender name 13 | sender_app_password = 'REPLACE_WITH_THE_SENDER_EMAIL_APP_PASSWORD' 14 | recipient_email ='REPLACE_WITH_THE_RECIPIENT_EMAIL' 15 | email_subject ='Test Email' 16 | 17 | def connect_wifi(ssid, password): 18 | #Connect to your network 19 | station = network.WLAN(network.STA_IF) 20 | station.active(True) 21 | station.connect(ssid, password) 22 | while station.isconnected() == False: 23 | pass 24 | print('Connection successful') 25 | print(station.ifconfig()) 26 | 27 | # Connect to your network 28 | connect_wifi(ssid, password) 29 | 30 | # Send the email 31 | smtp = umail.SMTP('smtp.gmail.com', 465, ssl=True) # Gmail's SSL port 32 | smtp.login(sender_email, sender_app_password) 33 | smtp.to(recipient_email) 34 | smtp.write("From:" + sender_name + "<"+ sender_email+">\n") 35 | smtp.write("Subject:" + email_subject + "\n") 36 | smtp.write("Hello from ESP32") 37 | smtp.send() 38 | smtp.quit() 39 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/esp_web_server_boot.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | try: 4 | import usocket as socket 5 | except: 6 | import socket 7 | 8 | from machine import Pin 9 | import network 10 | 11 | import esp 12 | esp.osdebug(None) 13 | 14 | import gc 15 | gc.collect() 16 | 17 | ssid = 'REPLACE_WITH_YOUR_SSID' 18 | password = 'REPLACE_WITH_YOUR_PASSWORD' 19 | 20 | station = network.WLAN(network.STA_IF) 21 | 22 | station.active(True) 23 | station.connect(ssid, password) 24 | 25 | while station.isconnected() == False: 26 | pass 27 | 28 | print('Connection successful') 29 | print(station.ifconfig()) 30 | 31 | led = Pin(2, Pin.OUT) 32 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/interrupts_esp32_esp8266.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com 2 | 3 | from machine import Pin 4 | from time import sleep 5 | 6 | motion = False 7 | 8 | def handle_interrupt(pin): 9 | global motion 10 | motion = True 11 | global interrupt_pin 12 | interrupt_pin = pin 13 | 14 | led = Pin(12, Pin.OUT) 15 | pir = Pin(14, Pin.IN) 16 | 17 | pir.irq(trigger=Pin.IRQ_RISING, handler=handle_interrupt) 18 | 19 | while True: 20 | if motion: 21 | print('Motion detected! Interrupt caused by:', interrupt_pin) 22 | led.value(1) 23 | sleep(20) 24 | led.value(0) 25 | print('Motion stopped!') 26 | motion = False 27 | -------------------------------------------------------------------------------- /Projects/ESP-MicroPython/oled/draw_shapes.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/micropython-ssd1306-oled-scroll-shapes-esp32-esp8266/ 2 | 3 | from machine import Pin, SoftI2C 4 | import ssd1306 5 | from time import sleep 6 | import gfx 7 | 8 | # ESP32 Pin assignment 9 | i2c = SoftI2C(scl=Pin(22), sda=Pin(21)) 10 | 11 | # ESP8266 Pin assignment 12 | #i2c = SoftI2C(scl=Pin(5), sda=Pin(4)) 13 | 14 | oled_width = 128 15 | oled_height = 64 16 | oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) 17 | 18 | graphics = gfx.GFX(oled_width, oled_height, oled.pixel) 19 | 20 | while True: 21 | 22 | graphics.line(0, 0, 127, 20, 1) 23 | oled.show() 24 | sleep(1) 25 | oled.fill(0) 26 | 27 | graphics.rect(10, 10, 50, 30, 1) 28 | oled.show() 29 | sleep(1) 30 | oled.fill(0) 31 | 32 | graphics.fill_rect(10, 10, 50, 30, 1) 33 | oled.show() 34 | sleep(1) 35 | oled.fill(0) 36 | 37 | 38 | graphics.circle(64, 32, 10, 1) 39 | oled.show() 40 | sleep(1) 41 | oled.fill(0) 42 | 43 | graphics.fill_circle(64, 32, 10, 1) 44 | oled.show() 45 | sleep(1) 46 | oled.fill(0) 47 | 48 | graphics.triangle(10,10,55,20,5,40,1) 49 | oled.show() 50 | sleep(1) 51 | oled.fill(0) 52 | 53 | graphics.fill_triangle(10,10,55,20,5,40,1) 54 | oled.show() 55 | sleep(1) 56 | oled.fill(0) 57 | -------------------------------------------------------------------------------- /Projects/ESP/ESP_Blink_VS_Code.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/vs-code-platformio-ide-esp32-esp8266-arduino/ 4 | *********/ 5 | 6 | #include 7 | 8 | #define LED 2 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(115200); 13 | pinMode(LED, OUTPUT); 14 | } 15 | 16 | void loop() { 17 | // put your main code here, to run repeatedly: 18 | digitalWrite(LED, HIGH); 19 | Serial.println("LED is on"); 20 | delay(1000); 21 | digitalWrite(LED, LOW); 22 | Serial.println("LED is off"); 23 | delay(1000); 24 | } 25 | -------------------------------------------------------------------------------- /Projects/ESP/ESP_Chart_Web_Server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP/ESP_Chart_Web_Server.zip -------------------------------------------------------------------------------- /Projects/ESP/ESP_DS18B20_Single.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com 4 | *********/ 5 | 6 | #include 7 | #include 8 | 9 | // GPIO where the DS18B20 is connected to 10 | const int oneWireBus = 4; 11 | 12 | // Setup a oneWire instance to communicate with any OneWire devices 13 | OneWire oneWire(oneWireBus); 14 | 15 | // Pass our oneWire reference to Dallas Temperature sensor 16 | DallasTemperature sensors(&oneWire); 17 | 18 | void setup() { 19 | // Start the Serial Monitor 20 | Serial.begin(115200); 21 | // Start the DS18B20 sensor 22 | sensors.begin(); 23 | } 24 | 25 | void loop() { 26 | sensors.requestTemperatures(); 27 | float temperatureC = sensors.getTempCByIndex(0); 28 | float temperatureF = sensors.getTempFByIndex(0); 29 | Serial.print(temperatureC); 30 | Serial.println("ºC"); 31 | Serial.print(temperatureF); 32 | Serial.println("ºF"); 33 | delay(5000); 34 | } 35 | -------------------------------------------------------------------------------- /Projects/ESP/ESP_Email_Attachments/ESP_Email_Attachments.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP/ESP_Email_Attachments/ESP_Email_Attachments.zip -------------------------------------------------------------------------------- /Projects/ESP/ESP_Email_Attachments/data/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP/ESP_Email_Attachments/data/image.png -------------------------------------------------------------------------------- /Projects/ESP/ESP_Email_Attachments/data/text_file.txt: -------------------------------------------------------------------------------- 1 | ESP32 text file sample stored in SPIFFS 2 | -------------------------------------------------------------------------------- /Projects/ESP/ESP_Get_MAC_Address.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | #ifdef ESP32 8 | #include 9 | #include 10 | #else 11 | #include 12 | #endif 13 | 14 | void setup(){ 15 | Serial.begin(115200); 16 | 17 | Serial.print("ESP Board MAC Address: "); 18 | #ifdef ESP32 19 | WiFi.mode(WIFI_STA); 20 | WiFi.STA.begin(); 21 | uint8_t baseMac[6]; 22 | esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac); 23 | if (ret == ESP_OK) { 24 | Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n", 25 | baseMac[0], baseMac[1], baseMac[2], 26 | baseMac[3], baseMac[4], baseMac[5]); 27 | } else { 28 | Serial.println("Failed to read MAC address"); 29 | } 30 | #else 31 | Serial.println(WiFi.macAddress()); 32 | #endif 33 | } 34 | 35 | void loop(){ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Projects/ESP/data.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP/data.zip -------------------------------------------------------------------------------- /Projects/ESP32/AsyncElegantOTA/ESP32_Web_Server_OTA_SPIFFS/data.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/AsyncElegantOTA/ESP32_Web_Server_OTA_SPIFFS/data.zip -------------------------------------------------------------------------------- /Projects/ESP32/AsyncElegantOTA/ESP32_Web_Server_OTA_SPIFFS/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/AsyncElegantOTA/ESP32_Web_Server_OTA_SPIFFS/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/BLE/Web_BLE_App/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/BLE/Web_BLE_App/favicon.ico -------------------------------------------------------------------------------- /Projects/ESP32/BLE/Web_BLE_App/favicon.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/BLE/Web_BLE_App/favicon.zip -------------------------------------------------------------------------------- /Projects/ESP32/BLE/Web_BLE_App/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial, Helvetica, sans-serif; 3 | display: inline-block; 4 | text-align: center; 5 | } 6 | h1 { 7 | font-size: 1.8rem; 8 | color: white; 9 | } 10 | .topnav { 11 | overflow: hidden; 12 | background-color: #0A1128; 13 | } 14 | body { 15 | margin: 0; 16 | } 17 | .content { 18 | padding: 50px; 19 | } 20 | .card-grid { 21 | max-width: 800px; 22 | margin: 0 auto; 23 | margin-bottom: 30px; 24 | display: grid; 25 | grid-gap: 2rem; 26 | grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 27 | } 28 | .card { 29 | background-color: white; 30 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 31 | } 32 | button { 33 | color: white; 34 | padding: 14px 20px; 35 | margin: 8px 0; 36 | border: none; 37 | cursor: pointer; 38 | border-radius: 4px; 39 | } 40 | 41 | .onButton{ 42 | background-color: #1b8a94; 43 | } 44 | 45 | .offButton{ 46 | background-color: #5f6c6d; 47 | } 48 | 49 | .connectButton{ 50 | background-color: #24af37; 51 | } 52 | 53 | .disconnectButton{ 54 | background-color: #d13a30; 55 | } 56 | 57 | .gray-label { 58 | color: #bebebe; 59 | font-size: 1rem; 60 | } 61 | 62 | .reading { 63 | font-size: 1.8rem; 64 | } 65 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Blink_VS_Code.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/vs-code-pioarduino-ide-esp32/ 4 | *********/ 5 | 6 | #include 7 | 8 | #define LED 2 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(115200); 13 | pinMode(LED, OUTPUT); 14 | } 15 | 16 | void loop() { 17 | // put your main code here, to run repeatedly: 18 | digitalWrite(LED, HIGH); 19 | Serial.println("LED is on"); 20 | delay(1000); 21 | digitalWrite(LED, LOW); 22 | Serial.println("LED is off"); 23 | delay(1000); 24 | } 25 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Charts_Multiple_Series.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Charts_Multiple_Series.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Charts_Multiple_Series/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Charts_Multiple_Series/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Charts_Multiple_Series/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ESP IOT DASHBOARD 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

ESP WEB SERVER CHARTS

15 |
16 |
17 |
18 |
19 |

Temperature Chart

20 |
21 |
22 |
23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Charts_Multiple_Series/data/style.css: -------------------------------------------------------------------------------- 1 | /* Complete project details: https://randomnerdtutorials.com/esp32-plot-readings-charts-multiple/ */ 2 | 3 | html { 4 | font-family: Arial, Helvetica, sans-serif; 5 | display: inline-block; 6 | text-align: center; 7 | } 8 | h1 { 9 | font-size: 1.8rem; 10 | color: white; 11 | } 12 | p { 13 | font-size: 1.4rem; 14 | } 15 | .topnav { 16 | overflow: hidden; 17 | background-color: #0A1128; 18 | } 19 | body { 20 | margin: 0; 21 | } 22 | .content { 23 | padding: 5%; 24 | } 25 | .card-grid { 26 | max-width: 1200px; 27 | margin: 0 auto; 28 | display: grid; 29 | grid-gap: 2rem; 30 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 31 | } 32 | .card { 33 | background-color: white; 34 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 35 | } 36 | .card-title { 37 | font-size: 1.2rem; 38 | font-weight: bold; 39 | color: #034078 40 | } 41 | .chart-container { 42 | padding-right: 5%; 43 | padding-left: 5%; 44 | } 45 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Digital_Inputs_Outputs.ino: -------------------------------------------------------------------------------- 1 | // Complete Instructions: https://RandomNerdTutorials.com/esp32-digital-inputs-outputs-arduino/ 2 | 3 | // set pin numbers 4 | const int buttonPin = 4; // the number of the pushbutton pin 5 | const int ledPin = 5; // the number of the LED pin 6 | 7 | // variable for storing the pushbutton status 8 | int buttonState = 0; 9 | 10 | void setup() { 11 | Serial.begin(115200); 12 | // initialize the pushbutton pin as an input 13 | pinMode(buttonPin, INPUT); 14 | // initialize the LED pin as an output 15 | pinMode(ledPin, OUTPUT); 16 | } 17 | 18 | void loop() { 19 | // read the state of the pushbutton value 20 | buttonState = digitalRead(buttonPin); 21 | Serial.println(buttonState); 22 | // check if the pushbutton is pressed. 23 | // if it is, the buttonState is HIGH 24 | if (buttonState == HIGH) { 25 | // turn LED on 26 | digitalWrite(ledPin, HIGH); 27 | } else { 28 | // turn LED off 29 | digitalWrite(ledPin, LOW); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Email/ESP32_Email_Attachments.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Email/ESP32_Email_Attachments.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Email/data/ESP32-CAM-Test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Email/data/ESP32-CAM-Test.jpg -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Email/data/text_file.txt: -------------------------------------------------------------------------------- 1 | ESP32 text file sample stored in SPIFFS 2 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Gauges/ESP32_Gauges.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Gauges/ESP32_Gauges.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Gauges/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Gauges/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Gauges/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP IOT DASHBOARD 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

ESP WEB SERVER GAUGES

13 |
14 |
15 |
16 |
17 |

Temperature

18 | 19 |
20 |
21 |

Humidity

22 | 23 |
24 |
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Gauges/data/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial, Helvetica, sans-serif; 3 | display: inline-block; 4 | text-align: center; 5 | } 6 | h1 { 7 | font-size: 1.8rem; 8 | color: white; 9 | } 10 | p { 11 | font-size: 1.4rem; 12 | } 13 | .topnav { 14 | overflow: hidden; 15 | background-color: #0A1128; 16 | } 17 | body { 18 | margin: 0; 19 | } 20 | .content { 21 | padding: 5%; 22 | } 23 | .card-grid { 24 | max-width: 1200px; 25 | margin: 0 auto; 26 | display: grid; 27 | grid-gap: 2rem; 28 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 29 | } 30 | .card { 31 | background-color: white; 32 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 33 | } 34 | .card-title { 35 | font-size: 1.2rem; 36 | font-weight: bold; 37 | color: #034078 38 | } -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Get_MAC_Address.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | #include 8 | #include 9 | 10 | void readMacAddress(){ 11 | uint8_t baseMac[6]; 12 | esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac); 13 | if (ret == ESP_OK) { 14 | Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n", 15 | baseMac[0], baseMac[1], baseMac[2], 16 | baseMac[3], baseMac[4], baseMac[5]); 17 | } else { 18 | Serial.println("Failed to read MAC address"); 19 | } 20 | } 21 | 22 | void setup(){ 23 | Serial.begin(115200); 24 | 25 | WiFi.mode(WIFI_STA); 26 | WiFi.STA.begin(); 27 | 28 | Serial.print("[DEFAULT] ESP32 Board MAC Address: "); 29 | readMacAddress(); 30 | } 31 | 32 | void loop(){ 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_I2C_Master.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-i2c-master-slave-arduino/ 4 | ESP32 I2C Master Example: https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/examples/WireMaster/WireMaster.ino 5 | *********/ 6 | 7 | #include "Wire.h" 8 | 9 | #define I2C_DEV_ADDR 0x55 10 | 11 | uint32_t i = 0; 12 | 13 | void setup() { 14 | Serial.begin(115200); 15 | Serial.setDebugOutput(true); 16 | Wire.begin(); 17 | } 18 | 19 | void loop() { 20 | delay(5000); 21 | 22 | // Write message to the slave 23 | Wire.beginTransmission(I2C_DEV_ADDR); 24 | Wire.printf("Hello World! %lu", i++); 25 | uint8_t error = Wire.endTransmission(true); 26 | Serial.printf("endTransmission: %u\n", error); 27 | 28 | // Read 16 bytes from the slave 29 | uint8_t bytesReceived = Wire.requestFrom(I2C_DEV_ADDR, 16); 30 | 31 | Serial.printf("requestFrom: %u\n", bytesReceived); 32 | if ((bool)bytesReceived) { //If received more than zero bytes 33 | uint8_t temp[bytesReceived]; 34 | Wire.readBytes(temp, bytesReceived); 35 | log_print_buf(temp, bytesReceived); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_I2C_Slave.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-i2c-master-slave-arduino/ 4 | ESP32 I2C Slave example: https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/examples/WireSlave/WireSlave.ino 5 | *********/ 6 | 7 | #include "Wire.h" 8 | 9 | #define I2C_DEV_ADDR 0x55 10 | 11 | uint32_t i = 0; 12 | 13 | void onRequest() { 14 | Wire.print(i++); 15 | Wire.print(" Packets."); 16 | Serial.println("onRequest"); 17 | Serial.println(); 18 | } 19 | 20 | void onReceive(int len) { 21 | Serial.printf("onReceive[%d]: ", len); 22 | while (Wire.available()) { 23 | Serial.write(Wire.read()); 24 | } 25 | Serial.println(); 26 | } 27 | 28 | void setup() { 29 | Serial.begin(115200); 30 | Serial.setDebugOutput(true); 31 | Wire.onReceive(onReceive); 32 | Wire.onRequest(onRequest); 33 | Wire.begin((uint8_t)I2C_DEV_ADDR); 34 | 35 | /*#if CONFIG_IDF_TARGET_ESP32 36 | char message[64]; 37 | snprintf(message, 64, "%lu Packets.", i++); 38 | Wire.slaveWrite((uint8_t *)message, strlen(message)); 39 | Serial.print('Printing config %lu', i); 40 | #endif*/ 41 | } 42 | 43 | void loop() { 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Light_Sleep/ESP32_Light_Sleep_Timer_Wake_Up.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-light-sleep-arduino/ 4 | *********/ 5 | 6 | int counter = 0; 7 | const int ledPin = 2; // GPIO pin for onboard LED 8 | uint64_t sleepTime = 10000000; // Sleep duration in microseconds (10 seconds) 9 | 10 | void setup() { 11 | Serial.begin(115200); 12 | pinMode(ledPin, OUTPUT); 13 | 14 | // Enable wake-up by timer 15 | esp_err_t result = esp_sleep_enable_timer_wakeup(sleepTime); 16 | 17 | if (result == ESP_OK) { 18 | Serial.println("Timer Wake-Up set successfully as wake-up source."); 19 | } else { 20 | Serial.println("Failed to set Timer Wake-Up as wake-up source."); 21 | } 22 | } 23 | 24 | void loop() { 25 | Serial.printf("Counter: %d\n", counter); 26 | counter++; 27 | 28 | digitalWrite(ledPin, HIGH); // LED on to indicate wake-up 29 | delay(2000); 30 | digitalWrite(ledPin, LOW); // Turn off LED before going to sleep 31 | 32 | Serial.println("Going into light sleep mode"); 33 | delay(500); 34 | esp_light_sleep_start(); // Enter light sleep 35 | Serial.println("Returning from light sleep"); 36 | } 37 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_MPU_6050_Web_Server/ESP32_MPU_6050_Web_Server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_MPU_6050_Web_Server/ESP32_MPU_6050_Web_Server.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Multiple_Sliders_Web_Server/ESP32_Multiple_Sliders_Web_Server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Multiple_Sliders_Web_Server/ESP32_Multiple_Sliders_Web_Server.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Multiple_Sliders_Web_Server/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Multiple_Sliders_Web_Server/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_NEO_6M_GPS_Basic_Serial.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete instructions at https://RandomNerdTutorials.com/esp32-neo-6m-gps-module-arduino/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | *********/ 7 | 8 | // Define the RX and TX pins for Serial 2 9 | #define RXD2 16 10 | #define TXD2 17 11 | 12 | #define GPS_BAUD 9600 13 | 14 | // Create an instance of the HardwareSerial class for Serial 2 15 | HardwareSerial gpsSerial(2); 16 | 17 | void setup(){ 18 | // Serial Monitor 19 | Serial.begin(115200); 20 | 21 | // Start Serial 2 with the defined RX and TX pins and a baud rate of 9600 22 | gpsSerial.begin(GPS_BAUD, SERIAL_8N1, RXD2, TXD2); 23 | Serial.println("Serial 2 started at 9600 baud rate"); 24 | } 25 | 26 | void loop(){ 27 | while (gpsSerial.available() > 0){ 28 | // get the byte data from the GPS 29 | char gpsData = gpsSerial.read(); 30 | Serial.print(gpsData); 31 | } 32 | delay(1000); 33 | Serial.println("-------------------------------"); 34 | } 35 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_NEO_M8N_GPS_Testing.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete instructions at https://RandomNerdTutorials.com/esp32-neo-m8n-gps-logger-google-earth/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | *********/ 7 | 8 | // Define the RX and TX pins for Serial 2 9 | #define RXD2 16 10 | #define TXD2 17 11 | 12 | #define GPS_BAUD 9600 13 | 14 | // Create an instance of the HardwareSerial class for Serial 2 15 | HardwareSerial gpsSerial(2); 16 | 17 | void setup(){ 18 | // Serial Monitor 19 | Serial.begin(115200); 20 | 21 | // Start Serial 2 with the defined RX and TX pins and a baud rate of 9600 22 | gpsSerial.begin(GPS_BAUD, SERIAL_8N1, RXD2, TXD2); 23 | Serial.println("Serial 2 started at 9600 baud rate"); 24 | } 25 | 26 | void loop(){ 27 | while (gpsSerial.available() > 0){ 28 | // get the byte data from the GPS 29 | char gpsData = gpsSerial.read(); 30 | Serial.print(gpsData); 31 | } 32 | delay(1000); 33 | Serial.println("-------------------------------"); 34 | } 35 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_RFID_User_Management_WS/ESP32_RFID_User_Management_WS.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_RFID_User_Management_WS/ESP32_RFID_User_Management_WS.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_RFID_User_Management_WS/data/get.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Add User 7 | 8 | 9 | 10 | 20 |
21 |
22 |

%inputmessage%

23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Read_Files_LittleFS.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-littlefs-arduino-ide/ 4 | *********/ 5 | 6 | #include "LittleFS.h" 7 | 8 | void setup() { 9 | Serial.begin(115200); 10 | 11 | if(!LittleFS.begin()){ 12 | Serial.println("An Error has occurred while mounting SPIFFS"); 13 | return; 14 | } 15 | 16 | File file = LittleFS.open("/test_example.txt"); 17 | if(!file){ 18 | Serial.println("Failed to open file for reading"); 19 | return; 20 | } 21 | 22 | Serial.println("File Content:"); 23 | while(file.available()){ 24 | Serial.write(file.read()); 25 | } 26 | file.close(); 27 | } 28 | 29 | void loop() { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Relay_Control.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp32-relay-module-ac-web-server/ 4 | 5 | The above copyright notice and this permission notice shall be included in all 6 | copies or substantial portions of the Software. 7 | *********/ 8 | 9 | const int relay = 26; 10 | 11 | void setup() { 12 | Serial.begin(115200); 13 | pinMode(relay, OUTPUT); 14 | } 15 | 16 | void loop() { 17 | // Normally Open configuration, send LOW signal to let current flow 18 | // (if you're usong Normally Closed configuration send HIGH signal) 19 | digitalWrite(relay, LOW); 20 | Serial.println("Current Flowing"); 21 | delay(5000); 22 | 23 | // Normally Open configuration, send HIGH signal stop current flow 24 | // (if you're usong Normally Closed configuration send LOW signal) 25 | digitalWrite(relay, HIGH); 26 | Serial.println("Current not Flowing"); 27 | delay(5000); 28 | } 29 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Sensor_Readings_WebSocket/ESP32_Sensor_Readings_WebSocket.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Sensor_Readings_WebSocket/ESP32_Sensor_Readings_WebSocket.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Sensor_Readings_WebSocket/data/script.js: -------------------------------------------------------------------------------- 1 | 2 | var gateway = `ws://${window.location.hostname}/ws`; 3 | var websocket; 4 | // Init web socket when the page loads 5 | window.addEventListener('load', onload); 6 | 7 | function onload(event) { 8 | initWebSocket(); 9 | } 10 | 11 | function getReadings(){ 12 | websocket.send("getReadings"); 13 | } 14 | 15 | function initWebSocket() { 16 | console.log('Trying to open a WebSocket connection…'); 17 | websocket = new WebSocket(gateway); 18 | websocket.onopen = onOpen; 19 | websocket.onclose = onClose; 20 | websocket.onmessage = onMessage; 21 | } 22 | 23 | // When websocket is established, call the getReadings() function 24 | function onOpen(event) { 25 | console.log('Connection opened'); 26 | getReadings(); 27 | } 28 | 29 | function onClose(event) { 30 | console.log('Connection closed'); 31 | setTimeout(initWebSocket, 2000); 32 | } 33 | 34 | // Function that receives the message from the ESP32 with the readings 35 | function onMessage(event) { 36 | console.log(event.data); 37 | var myObj = JSON.parse(event.data); 38 | var keys = Object.keys(myObj); 39 | 40 | for (var i = 0; i < keys.length; i++){ 41 | var key = keys[i]; 42 | document.getElementById(key).innerHTML = myObj[key]; 43 | } 44 | } -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Sensor_Readings_WebSocket/data/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial, Helvetica, sans-serif; 3 | display: inline-block; 4 | text-align: center; 5 | } 6 | h1 { 7 | font-size: 1.8rem; 8 | color: white; 9 | } 10 | .topnav { 11 | overflow: hidden; 12 | background-color: #0A1128; 13 | } 14 | body { 15 | margin: 0; 16 | } 17 | .content { 18 | padding: 50px; 19 | } 20 | .card-grid { 21 | max-width: 800px; 22 | margin: 0 auto; 23 | display: grid; 24 | grid-gap: 2rem; 25 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 26 | } 27 | .card { 28 | background-color: white; 29 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 30 | } 31 | .card-title { 32 | font-size: 1.2rem; 33 | font-weight: bold; 34 | color: #034078 35 | } 36 | .reading { 37 | font-size: 1.2rem; 38 | color: #1282A2; 39 | } -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Servo_Sweep.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-servo-motor-web-server-arduino-ide/ 4 | Based on the ESP32Servo Sweep Example 5 | *********/ 6 | 7 | #include 8 | 9 | static const int servoPin = 13; 10 | 11 | Servo servo1; 12 | 13 | void setup() { 14 | 15 | Serial.begin(115200); 16 | servo1.attach(servoPin); 17 | } 18 | 19 | void loop() { 20 | for(int posDegrees = 0; posDegrees <= 180; posDegrees++) { 21 | servo1.write(posDegrees); 22 | Serial.println(posDegrees); 23 | delay(20); 24 | } 25 | 26 | for(int posDegrees = 180; posDegrees >= 0; posDegrees--) { 27 | servo1.write(posDegrees); 28 | Serial.println(posDegrees); 29 | delay(20); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Stepper_Motor_WS_Styled/ESP32_Stepper_Motor_WS_Styled.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Stepper_Motor_WS_Styled/ESP32_Stepper_Motor_WS_Styled.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Stepper_Motor_WS_Styled/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Stepper_Motor_WS_Styled/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Stepper_Motor_WS_Styled/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Stepper Motor 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

Stepper Motor Control

13 |
14 |
15 |
16 | 17 | 18 | 19 |


20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Stepper_Motor_Websocket/ESP32_Stepper_Motor_Websocket.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Stepper_Motor_Websocket/ESP32_Stepper_Motor_Websocket.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Stepper_Motor_Websocket/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_Stepper_Motor_Websocket/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_Thermocouple.ino: -------------------------------------------------------------------------------- 1 | // this example is public domain. enjoy! https://learn.adafruit.com/thermocouple/ 2 | 3 | #include "max6675.h" 4 | 5 | int thermoDO = 19; 6 | int thermoCS = 23; 7 | int thermoCLK = 5; 8 | 9 | MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | 14 | Serial.println("MAX6675 test"); 15 | // wait for MAX chip to stabilize 16 | delay(500); 17 | } 18 | 19 | void loop() { 20 | // basic readout test, just print the current temp 21 | 22 | Serial.print("C = "); 23 | Serial.println(thermocouple.readCelsius()); 24 | Serial.print("F = "); 25 | Serial.println(thermocouple.readFahrenheit()); 26 | 27 | // For the MAX6675 to update, you must delay AT LEAST 250ms between reads! 28 | delay(1000); 29 | } 30 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_VS_Code_LittleFS_Test.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-vs-code-platformio-littlefs/ 4 | *********/ 5 | 6 | #include 7 | #include "LittleFS.h" 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | 12 | if(!LittleFS.begin(true)){ 13 | Serial.println("An Error has occurred while mounting LittleFS"); 14 | return; 15 | } 16 | 17 | File file = LittleFS.open("/text.txt"); 18 | if(!file){ 19 | Serial.println("Failed to open file for reading"); 20 | return; 21 | } 22 | 23 | Serial.println("File Content:"); 24 | while(file.available()){ 25 | Serial.write(file.read()); 26 | } 27 | file.close(); 28 | } 29 | 30 | void loop() { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_WiFiScan.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example from WiFi > WiFiScan 3 | Complete details at https://RandomNerdTutorials.com/esp32-useful-wi-fi-functions-arduino/ 4 | */ 5 | 6 | #include "WiFi.h" 7 | 8 | void setup() { 9 | Serial.begin(115200); 10 | 11 | // Set WiFi to station mode and disconnect from an AP if it was previously connected 12 | WiFi.mode(WIFI_STA); 13 | WiFi.disconnect(); 14 | delay(100); 15 | 16 | Serial.println("Setup done"); 17 | } 18 | 19 | void loop() { 20 | Serial.println("scan start"); 21 | 22 | // WiFi.scanNetworks will return the number of networks found 23 | int n = WiFi.scanNetworks(); 24 | Serial.println("scan done"); 25 | if (n == 0) { 26 | Serial.println("no networks found"); 27 | } else { 28 | Serial.print(n); 29 | Serial.println(" networks found"); 30 | for (int i = 0; i < n; ++i) { 31 | // Print SSID and RSSI for each network found 32 | Serial.print(i + 1); 33 | Serial.print(": "); 34 | Serial.print(WiFi.SSID(i)); 35 | Serial.print(" ("); 36 | Serial.print(WiFi.RSSI(i)); 37 | Serial.print(")"); 38 | Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); 39 | delay(10); 40 | } 41 | } 42 | Serial.println(""); 43 | 44 | // Wait a bit before scanning again 45 | delay(5000); 46 | } 47 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_WiFi_Manager/ESP32_WiFi_Manager.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_WiFi_Manager/ESP32_WiFi_Manager.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_WiFi_Manager/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP32_WiFi_Manager/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_WiFi_Manager/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP WEB SERVER 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

ESP WEB SERVER

13 |
14 |
15 |
16 |
17 |

GPIO 2

18 |

19 | 20 | 21 |

22 |

State: %STATE%

23 |
24 |
25 |
26 | 27 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_WiFi_Manager/data/wifimanager.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP Wi-Fi Manager 5 | 6 | 7 | 8 | 9 | 10 |
11 |

ESP Wi-Fi Manager

12 |
13 |
14 |
15 |
16 |
17 |

18 | 19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 |

28 |
29 |
30 |
31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_WiFi_Signal_Strength.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Complete details at https://RandomNerdTutorials.com/esp32-useful-wi-fi-functions-arduino/ 3 | */ 4 | 5 | #include 6 | 7 | // Replace with your network credentials (STATION) 8 | const char* ssid = "REPLACE_WITH_YOUR_SSID"; 9 | const char* password = "REPLACE_WITH_YOUR_PASSWORD"; 10 | 11 | void initWiFi() { 12 | WiFi.mode(WIFI_STA); 13 | WiFi.begin(ssid, password); 14 | Serial.print("Connecting to WiFi .."); 15 | while (WiFi.status() != WL_CONNECTED) { 16 | Serial.print('.'); 17 | delay(1000); 18 | } 19 | Serial.println(WiFi.localIP()); 20 | } 21 | 22 | void setup() { 23 | Serial.begin(115200); 24 | initWiFi(); 25 | Serial.print("RRSI: "); 26 | Serial.println(WiFi.RSSI()); 27 | } 28 | 29 | void loop() { 30 | // put your main code here, to run repeatedly: 31 | } 32 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_analogWrite.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-pwm-arduino-ide/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | 8 | // the number of the LED pin 9 | const int ledPin = 16; // 16 corresponds to GPIO 16 10 | 11 | void setup() { 12 | // set the LED as an output 13 | pinMode(ledPin, OUTPUT); 14 | } 15 | 16 | void loop(){ 17 | // increase the LED brightness 18 | for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){ 19 | // changing the LED brightness with PWM 20 | analogWrite(ledPin, dutyCycle); 21 | delay(15); 22 | } 23 | 24 | // decrease the LED brightness 25 | for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){ 26 | // changing the LED brightness with PWM 27 | analogWrite(ledPin, dutyCycle); 28 | delay(15); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP32_ledcWrite.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/esp32-pwm-arduino-ide/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | 8 | // the number of the LED pin 9 | const int ledPin = 16; // 16 corresponds to GPIO16 10 | 11 | // setting PWM properties 12 | const int freq = 5000; 13 | const int resolution = 8; 14 | 15 | void setup(){ 16 | // configure LED PWM 17 | ledcAttach(ledPin, freq, resolution); 18 | 19 | // if you want to attach a specific channel, use the following instead 20 | //ledcAttachChannel(ledPin, freq, resolution, 0); 21 | } 22 | 23 | void loop(){ 24 | // increase the LED brightness 25 | for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){ 26 | // changing the LED brightness with PWM 27 | ledcWrite(ledPin, dutyCycle); 28 | delay(15); 29 | } 30 | 31 | // decrease the LED brightness 32 | for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){ 33 | // changing the LED brightness with PWM 34 | ledcWrite(ledPin, dutyCycle); 35 | delay(15); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Projects/ESP32/ESP3_LoRa/ESP3_LoRa.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP3_LoRa/ESP3_LoRa.zip -------------------------------------------------------------------------------- /Projects/ESP32/ESP3_LoRa/LoRa_Receiver_Web_Server/data/winter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ESP3_LoRa/LoRa_Receiver_Web_Server/data/winter.jpg -------------------------------------------------------------------------------- /Projects/ESP32/ElegantOTA/ESP32_WebServer_LED_ElegantOTA_2/ESP32_WebServer_LED_ElegantOTA_2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ElegantOTA/ESP32_WebServer_LED_ElegantOTA_2/ESP32_WebServer_LED_ElegantOTA_2.zip -------------------------------------------------------------------------------- /Projects/ESP32/ElegantOTA/ESP32_WebServer_LED_ElegantOTA_2/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/ElegantOTA/ESP32_WebServer_LED_ElegantOTA_2/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/ElegantOTA/ESP32_WebServer_LED_ElegantOTA_2/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP IOT DASHBOARD 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

ESP WEB SERVER

13 |
14 |
15 |
16 |
17 |

GPIO 2

18 |

19 | 20 | 21 |

22 |

State: %STATE%

23 |
24 |
25 |
26 | 27 | -------------------------------------------------------------------------------- /Projects/ESP32/ElegantOTA/ESP32_WebServer_LED_ElegantOTA_2/data/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial, Helvetica, sans-serif; 3 | text-align: center; 4 | } 5 | h1 { 6 | font-size: 1.8rem; 7 | color: white; 8 | } 9 | .topnav { 10 | overflow: hidden; 11 | background-color: #0A1128; 12 | } 13 | body { 14 | margin: 0; 15 | } 16 | .content { 17 | padding: 50px; 18 | } 19 | .card-grid { 20 | max-width: 800px; 21 | margin: 0 auto; 22 | display: grid; 23 | grid-gap: 2rem; 24 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 25 | } 26 | .card { 27 | background-color: white; 28 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 29 | } 30 | .card-title { 31 | font-size: 1.2rem; 32 | font-weight: bold; 33 | color: #034078 34 | } 35 | .state { 36 | font-size: 1.2rem; 37 | color:#1282A2; 38 | } 39 | button { 40 | border: none; 41 | color: #FEFCFB; 42 | padding: 15px 32px; 43 | text-align: center; 44 | font-size: 16px; 45 | width: 100px; 46 | border-radius: 4px; 47 | transition-duration: 0.4s; 48 | } 49 | .button-on { 50 | background-color:#034078; 51 | } 52 | .button-on:hover { 53 | background-color: #1282A2; 54 | } 55 | .button-off { 56 | background-color:#858585; 57 | } 58 | .button-off:hover { 59 | background-color: #252524; 60 | } -------------------------------------------------------------------------------- /Projects/ESP32/Find_DS18B20_Addresses.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details https://randomnerdtutorials.com 4 | */ 5 | 6 | #include 7 | 8 | // Based on the OneWire library example 9 | 10 | OneWire ds(4); //data wire connected to GPIO 4 11 | 12 | void setup(void) { 13 | Serial.begin(115200); 14 | } 15 | 16 | void loop(void) { 17 | byte i; 18 | byte addr[8]; 19 | 20 | if (!ds.search(addr)) { 21 | Serial.println(" No more addresses."); 22 | Serial.println(); 23 | ds.reset_search(); 24 | delay(250); 25 | return; 26 | } 27 | Serial.print(" ROM ="); 28 | for (i = 0; i < 8; i++) { 29 | Serial.write(' '); 30 | Serial.print(addr[i], HEX); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Projects/ESP32/MicroSD_Card/files/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/MicroSD_Card/files/favicon.png -------------------------------------------------------------------------------- /Projects/ESP32/MicroSD_Card/files/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ESP Web Server 7 | 8 | 9 |

Hello World!

10 |

This page was built with files from a microSD card.

11 | 12 | 13 | -------------------------------------------------------------------------------- /Projects/ESP32/MicroSD_Card/files/index.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/MicroSD_Card/files/index.zip -------------------------------------------------------------------------------- /Projects/ESP32/MicroSD_Card/files/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial; 3 | text-align: center; 4 | } 5 | body { 6 | max-width: 400px; 7 | margin:0px auto; 8 | } -------------------------------------------------------------------------------- /Projects/ESP32/MicroSD_Card/files/style.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP32/MicroSD_Card/files/style.zip -------------------------------------------------------------------------------- /Projects/ESP32/Preferences/ESP32_Save_Credentials.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp32-save-data-permanently-preferences/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files. 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | */ 11 | 12 | #include 13 | 14 | Preferences preferences; 15 | 16 | const char* ssid = "REPLACE_WITH_YOUR_SSID"; 17 | const char* password = "REPLACE_WITH_YOUR_PASSWORD"; 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | Serial.println(); 22 | 23 | preferences.begin("credentials", false); 24 | preferences.putString("ssid", ssid); 25 | preferences.putString("password", password); 26 | 27 | Serial.println("Network Credentials Saved using Preferences"); 28 | 29 | preferences.end(); 30 | } 31 | 32 | void loop() { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Projects/ESP32/SPI/ESP32_Find_SPI_Pins.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp32-spi-communication-arduino/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files. 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | */ 11 | 12 | //Find the default SPI pins for your board 13 | //Make sure you have the right board selected in Tools > Boards 14 | void setup() { 15 | // put your setup code here, to run once: 16 | Serial.begin(115200); 17 | Serial.print("MOSI: "); 18 | Serial.println(MOSI); 19 | Serial.print("MISO: "); 20 | Serial.println(MISO); 21 | Serial.print("SCK: "); 22 | Serial.println(SCK); 23 | Serial.print("SS: "); 24 | Serial.println(SS); 25 | } 26 | 27 | void loop() { 28 | // put your main code here, to run repeatedly: 29 | } 30 | -------------------------------------------------------------------------------- /Projects/ESP32/UART/UART_Receiver.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete instructions at https://RandomNerdTutorials.com/esp32-uart-communication-serial-arduino/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | *********/ 7 | 8 | // Define TX and RX pins for UART (change if needed) 9 | #define TXD1 19 10 | #define RXD1 21 11 | 12 | // Use Serial1 for UART communication 13 | HardwareSerial mySerial(2); 14 | 15 | void setup() { 16 | Serial.begin(115200); 17 | mySerial.begin(9600, SERIAL_8N1, RXD1, TXD1); // UART setup 18 | 19 | Serial.println("ESP32 UART Receiver"); 20 | } 21 | 22 | void loop() { 23 | // Check if data is available to read 24 | if (mySerial.available()) { 25 | // Read data and display it 26 | String message = mySerial.readStringUntil('\n'); 27 | Serial.println("Received: " + message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/ESP32/UART/UART_Sender.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete instructions at https://RandomNerdTutorials.com/esp32-uart-communication-serial-arduino/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | *********/ 7 | 8 | // Define TX and RX pins for UART (change if needed) 9 | #define TXD1 19 10 | #define RXD1 21 11 | 12 | // Use Serial1 for UART communication 13 | HardwareSerial mySerial(1); 14 | 15 | int counter = 0; 16 | 17 | void setup() { 18 | Serial.begin(115200); 19 | mySerial.begin(9600, SERIAL_8N1, RXD1, TXD1); // UART setup 20 | 21 | Serial.println("ESP32 UART Transmitter"); 22 | } 23 | 24 | void loop() { 25 | 26 | // Send message over UART 27 | mySerial.println(String(counter)); 28 | 29 | Serial.println("Sent: " + String(counter)); 30 | 31 | // increment the counter 32 | counter++; 33 | 34 | delay(1000); 35 | } 36 | -------------------------------------------------------------------------------- /Projects/ESP32/VS_Code/VS_Code_SPIFFS_Test.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp32-vs-code-platformio-spiffs/ 4 | *********/ 5 | 6 | #include 7 | #include "SPIFFS.h" 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | 12 | if(!SPIFFS.begin(true)){ 13 | Serial.println("An Error has occurred while mounting SPIFFS"); 14 | return; 15 | } 16 | 17 | File file = SPIFFS.open("/text.txt"); 18 | if(!file){ 19 | Serial.println("Failed to open file for reading"); 20 | return; 21 | } 22 | 23 | Serial.println("File Content:"); 24 | while(file.available()){ 25 | Serial.write(file.read()); 26 | } 27 | file.close(); 28 | } 29 | 30 | void loop() { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Projects/ESP32_Button_LED.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | * Ardino IDE Example: Arduino button with LED 5 | */ 6 | 7 | // constants won't change. They're used here to 8 | // set pin numbers: 9 | const int buttonPin = 4; // the number of the pushbutton pin 10 | const int ledPin = 16; // the number of the LED pin 11 | 12 | // variables will change: 13 | int buttonState = 0; // variable for reading the pushbutton status 14 | 15 | void setup() { 16 | // initialize the LED pin as an output: 17 | pinMode(ledPin, OUTPUT); 18 | // initialize the pushbutton pin as an input: 19 | pinMode(buttonPin, INPUT); 20 | } 21 | 22 | void loop() { 23 | // read the state of the pushbutton value: 24 | buttonState = digitalRead(buttonPin); 25 | 26 | // check if the pushbutton is pressed. 27 | // if it is, the buttonState is HIGH: 28 | if (buttonState == HIGH) { 29 | // turn LED on: 30 | digitalWrite(ledPin, HIGH); 31 | } else { 32 | // turn LED off: 33 | digitalWrite(ledPin, LOW); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Projects/ESP8266-Bitcoin-Price/bitcoinprice.lua: -------------------------------------------------------------------------------- 1 | wifi.setmode(wifi.STATION) 2 | wifi.sta.config("YOUR_NETWORK_NAME","YOUR_NETWORK_PASSWORD") 3 | print(wifi.sta.getip()) 4 | conn=net.createConnection(net.TCP, 0) 5 | conn:on("receive", function(conn, payload) print(payload) end ) 6 | conn:connect(80,"api.coindesk.com") 7 | conn:send("GET /v1/bpi/currentprice.json HTTP/1.1\r\nHost: api.coindesk.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") 8 | -------------------------------------------------------------------------------- /Projects/ESP8266-Communication/client.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos 2 | -- Complete project details at http://randomnerdtutorials.com 3 | -- ESP8266 Client 4 | 5 | print("ESP8266 Client") 6 | wifi.sta.disconnect() 7 | wifi.setmode(wifi.STATION) 8 | wifi.sta.config("test","12345678") -- connecting to server 9 | wifi.sta.connect() 10 | print("Looking for a connection") 11 | 12 | tmr.alarm(1, 2000, 1, function() 13 | if(wifi.sta.getip()~=nil) then 14 | tmr.stop(1) 15 | print("Connected!") 16 | print("Client IP Address:",wifi.sta.getip()) 17 | cl=net.createConnection(net.TCP, 0) 18 | cl:connect(80,"192.168.4.1") 19 | tmr.alarm(2, 5000, 1, function() 20 | cl:send("Hello World!") 21 | end) 22 | else 23 | print("Connecting...") 24 | end 25 | end) 26 | -------------------------------------------------------------------------------- /Projects/ESP8266-Communication/server.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos 2 | -- Complete project details at http://randomnerdtutorials.com 3 | -- ESP8266 Server 4 | 5 | print("ESP8266 Server") 6 | wifi.setmode(wifi.STATIONAP); 7 | wifi.ap.config({ssid="test",pwd="12345678"}); 8 | print("Server IP Address:",wifi.ap.getip()) 9 | 10 | sv = net.createServer(net.TCP) 11 | sv:listen(80, function(conn) 12 | conn:on("receive", function(conn, receivedData) 13 | print("Received Data: " .. receivedData) 14 | end) 15 | conn:on("sent", function(conn) 16 | collectgarbage() 17 | end) 18 | end) 19 | -------------------------------------------------------------------------------- /Projects/ESP8266-Serial-Communication-with-Arduino/Arduino_talks_with_ESP8266.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | // Send Data From Arduino to ESP8266 via Serial @ baud rate 9600 7 | void setup() { 8 | Serial.begin(9600); 9 | } 10 | 11 | void loop() { 12 | Serial.print("HI!"); 13 | delay(1000); 14 | } 15 | -------------------------------------------------------------------------------- /Projects/ESP8266-Serial-Communication-with-Arduino/init.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos 2 | -- Complete project details at http://randomnerdtutorials.com 3 | 4 | ledOn = 0 5 | pin=4 6 | gpio.mode(pin,gpio.OUTPUT) 7 | uart.on("data", 3, 8 | function(data) 9 | print("Received from Arduino:", data) 10 | if data=="HI!" then 11 | if ledOn==0 then 12 | ledOn = 1 13 | gpio.write(pin,gpio.HIGH) 14 | print("LED On") 15 | else 16 | ledOn = 0 17 | gpio.write(pin,gpio.LOW) 18 | print("LED Off") 19 | end 20 | end 21 | end, 0) 22 | -------------------------------------------------------------------------------- /Projects/ESP8266/AsyncElegantOTA/ESP8266_Web_Server_OTA_SPIFFS/data.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/AsyncElegantOTA/ESP8266_Web_Server_OTA_SPIFFS/data.zip -------------------------------------------------------------------------------- /Projects/ESP8266/AsyncElegantOTA/ESP8266_Web_Server_OTA_SPIFFS/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/AsyncElegantOTA/ESP8266_Web_Server_OTA_SPIFFS/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Analog_Read_ADC0.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at http://randomnerdtutorials.com 4 | *********/ 5 | 6 | const int analogInPin = A0; // ESP8266 Analog Pin ADC0 = A0 7 | 8 | int sensorValue = 0; // value read from the pot 9 | 10 | void setup() { 11 | // initialize serial communication at 115200 12 | Serial.begin(115200); 13 | } 14 | 15 | void loop() { 16 | // read the analog in value 17 | sensorValue = analogRead(analogInPin); 18 | 19 | // print the readings in the Serial Monitor 20 | Serial.print("sensor = "); 21 | Serial.print(sensorValue); 22 | 23 | delay(1000); 24 | } 25 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Change_MAC_Address.ino: -------------------------------------------------------------------------------- 1 | // Complete Instructions: https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/ 2 | 3 | #include 4 | 5 | // Set your new MAC Address 6 | uint8_t newMACAddress[] = {0x32, 0xAE, 0xA4, 0x07, 0x0D, 0x66}; 7 | 8 | void setup(){ 9 | Serial.begin(115200); 10 | Serial.println(); 11 | 12 | WiFi.mode(WIFI_STA); 13 | 14 | Serial.print("[OLD] ESP8266 Board MAC Address: "); 15 | Serial.println(WiFi.macAddress()); 16 | 17 | // For Soft Access Point (AP) Mode 18 | //wifi_set_macaddr(SOFTAP_IF, &newMACAddress[0]); 19 | // For Station Mode 20 | wifi_set_macaddr(STATION_IF, &newMACAddress[0]); 21 | 22 | Serial.print("[NEW] ESP8266 Board MAC Address: "); 23 | Serial.println(WiFi.macAddress()); 24 | } 25 | 26 | void loop(){ 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Charts_Multiple_Series.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Charts_Multiple_Series.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Charts_Multiple_Series/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Charts_Multiple_Series/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Charts_Multiple_Series/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ESP IOT DASHBOARD 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

ESP WEB SERVER CHARTS

15 |
16 |
17 |
18 |
19 |

Temperature Chart

20 |
21 |
22 |
23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Charts_Multiple_Series/data/style.css: -------------------------------------------------------------------------------- 1 | /* Complete project details: https://randomnerdtutorials.com/esp8266-nodemcu-plot-readings-charts-multiple/ */ 2 | 3 | html { 4 | font-family: Arial, Helvetica, sans-serif; 5 | display: inline-block; 6 | text-align: center; 7 | } 8 | h1 { 9 | font-size: 1.8rem; 10 | color: white; 11 | } 12 | p { 13 | font-size: 1.4rem; 14 | } 15 | .topnav { 16 | overflow: hidden; 17 | background-color: #0A1128; 18 | } 19 | body { 20 | margin: 0; 21 | } 22 | .content { 23 | padding: 5%; 24 | } 25 | .card-grid { 26 | max-width: 1200px; 27 | margin: 0 auto; 28 | display: grid; 29 | grid-gap: 2rem; 30 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 31 | } 32 | .card { 33 | background-color: white; 34 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 35 | } 36 | .card-title { 37 | font-size: 1.2rem; 38 | font-weight: bold; 39 | color: #034078 40 | } 41 | .chart-container { 42 | padding-right: 5%; 43 | padding-left: 5%; 44 | } 45 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_DC_Motor_Web_Server/ESP8266_DC_Motor_Web_Server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_DC_Motor_Web_Server/ESP8266_DC_Motor_Web_Server.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_DC_Motor_Web_Server/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_DC_Motor_Web_Server/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_DC_Motor_Web_Server/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP IOT DASHBOARD 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

CONTROL DC MOTOR

13 |
14 |
15 |
16 |
17 |

DC Motor A

18 |

19 | 20 | 21 |

22 |

23 | 24 |

25 |
26 |
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Digital_Inputs_Outputs.ino: -------------------------------------------------------------------------------- 1 | // Complete Instructions: https://RandomNerdTutorials.com/esp8266-nodemcu-digital-inputs-outputs-arduino/ 2 | 3 | // set pin numbers 4 | const int buttonPin = 4; // the number of the pushbutton pin 5 | const int ledPin = 5; // the number of the LED pin 6 | 7 | // variable for storing the pushbutton status 8 | int buttonState = 0; 9 | 10 | void setup() { 11 | // initialize the pushbutton pin as an input 12 | pinMode(buttonPin, INPUT); 13 | // initialize the LED pin as an output 14 | pinMode(ledPin, OUTPUT); 15 | } 16 | 17 | void loop() { 18 | // read the state of the pushbutton value 19 | buttonState = digitalRead(buttonPin); 20 | // check if the pushbutton is pressed. 21 | // if it is, the buttonState is HIGH 22 | if (buttonState == HIGH) { 23 | // turn LED on 24 | digitalWrite(ledPin, HIGH); 25 | } else { 26 | // turn LED off 27 | digitalWrite(ledPin, LOW); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Email_Attachments/ESP8266_Email_Attachments.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Email_Attachments/ESP8266_Email_Attachments.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Email_Attachments/data/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Email_Attachments/data/image.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Email_Attachments/data/text_file.txt: -------------------------------------------------------------------------------- 1 | ESP32 text file sample stored in SPIFFS 2 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Filesystem_Example.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com 4 | *********/ 5 | 6 | #include "FS.h" 7 | 8 | void setup() { 9 | Serial.begin(115200); 10 | 11 | if(!SPIFFS.begin()){ 12 | Serial.println("An Error has occurred while mounting SPIFFS"); 13 | return; 14 | } 15 | 16 | File file = SPIFFS.open("/test_example.txt", "r"); 17 | if(!file){ 18 | Serial.println("Failed to open file for reading"); 19 | return; 20 | } 21 | 22 | Serial.println(); 23 | Serial.println("File Content:"); 24 | while(file.available()){ 25 | Serial.write(file.read()); 26 | } 27 | file.close(); 28 | } 29 | 30 | void loop() { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Gauges/ESP8266_Gauges.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Gauges/ESP8266_Gauges.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Gauges/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Gauges/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Gauges/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP IOT DASHBOARD 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |

ESP WEB SERVER GAUGES

14 |
15 |
16 |
17 |
18 |

Temperature

19 | 20 |
21 |
22 |

Humidity

23 | 24 |
25 |
26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Gauges/data/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial, Helvetica, sans-serif; 3 | display: inline-block; 4 | text-align: center; 5 | } 6 | h1 { 7 | font-size: 1.8rem; 8 | color: white; 9 | } 10 | p { 11 | font-size: 1.4rem; 12 | } 13 | .topnav { 14 | overflow: hidden; 15 | background-color: #0A1128; 16 | } 17 | body { 18 | margin: 0; 19 | } 20 | .content { 21 | padding: 5%; 22 | } 23 | .card-grid { 24 | max-width: 1200px; 25 | margin: 0 auto; 26 | display: grid; 27 | grid-gap: 2rem; 28 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 29 | } 30 | .card { 31 | background-color: white; 32 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 33 | } 34 | .card-title { 35 | font-size: 1.2rem; 36 | font-weight: bold; 37 | color: #034078 38 | } -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Get_MAC_Address.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/ 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | */ 7 | #include 8 | 9 | void setup(){ 10 | Serial.begin(115200); 11 | Serial.println(); 12 | Serial.print("ESP Board MAC Address: "); 13 | Serial.println(WiFi.macAddress()); 14 | } 15 | 16 | void loop(){ 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Multiple_Sliders_Web_Server/ESP8266_Multiple_Sliders_Web_Server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Multiple_Sliders_Web_Server/ESP8266_Multiple_Sliders_Web_Server.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Multiple_Sliders_Web_Server/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Multiple_Sliders_Web_Server/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_PWM_Fade_LED.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://randomnerdtutorials.com 4 | *********/ 5 | 6 | const int ledPin = 2; 7 | 8 | void setup() { 9 | 10 | } 11 | 12 | void loop() { 13 | // increase the LED brightness 14 | for(int dutyCycle = 0; dutyCycle < 255; dutyCycle++){ 15 | // changing the LED brightness with PWM 16 | analogWrite(ledPin, dutyCycle); 17 | delay(1); 18 | } 19 | 20 | // decrease the LED brightness 21 | for(int dutyCycle = 255; dutyCycle > 0; dutyCycle--){ 22 | // changing the LED brightness with PWM 23 | analogWrite(ledPin, dutyCycle); 24 | delay(1); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Relay_Control.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp8266-relay-module-ac-web-server/ 4 | 5 | The above copyright notice and this permission notice shall be included in all 6 | copies or substantial portions of the Software. 7 | *********/ 8 | 9 | const int relay = 5; 10 | 11 | void setup() { 12 | Serial.begin(115200); 13 | pinMode(relay, OUTPUT); 14 | } 15 | 16 | void loop() { 17 | // Normally Open configuration, send LOW signal to let current flow 18 | // (if you're usong Normally Closed configuration send HIGH signal) 19 | digitalWrite(relay, LOW); 20 | Serial.println("Current Flowing"); 21 | delay(5000); 22 | 23 | // Normally Open configuration, send HIGH signal stop current flow 24 | // (if you're usong Normally Closed configuration send LOW signal) 25 | digitalWrite(relay, HIGH); 26 | Serial.println("Current not Flowing"); 27 | delay(5000); 28 | } 29 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_SPIFFS/ESP8266_SPIFFS.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_SPIFFS/ESP8266_SPIFFS.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_SPIFFS/data/style.css: -------------------------------------------------------------------------------- 1 | /*** 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com 4 | ***/ 5 | 6 | html { 7 | font-family: Arial; 8 | display: inline-block; 9 | margin: 0px auto; 10 | text-align: center; 11 | } 12 | h1 { 13 | color: #0F3376; 14 | padding: 2vh; 15 | } 16 | p { 17 | font-size: 1.5rem; 18 | } 19 | .button { 20 | display: inline-block; 21 | background-color: #008CBA; 22 | border: none; 23 | border-radius: 4px; 24 | color: white; 25 | padding: 16px 40px; 26 | text-decoration: none; 27 | font-size: 30px; 28 | margin: 2px; 29 | cursor: pointer; 30 | } 31 | .button2 { 32 | background-color: #f44336; 33 | } 34 | .units { 35 | font-size: 1.2rem; 36 | } 37 | .sensor-labels { 38 | font-size: 1.5rem; 39 | vertical-align:middle; 40 | padding-bottom: 15px; 41 | } 42 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Sensor_Readings_WebSocket/ESP8266_Sensor_Readings_WebSocket.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Sensor_Readings_WebSocket/ESP8266_Sensor_Readings_WebSocket.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Sensor_Readings_WebSocket/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP IOT DASHBOARD 5 | 6 | 7 | 8 | 9 | 10 |
11 |

SENSOR READINGS (WEBSOCKET)

12 |
13 |
14 |
15 |
16 |

Temperature

17 |

°C

18 |
19 |
20 |

Humidity

21 |

%

22 |
23 |
24 |

Pressure

25 |

hpa

26 |
27 |
28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Sensor_Readings_WebSocket/data/script.js: -------------------------------------------------------------------------------- 1 | 2 | var gateway = `ws://${window.location.hostname}/ws`; 3 | var websocket; 4 | // Init web socket when the page loads 5 | window.addEventListener('load', onload); 6 | 7 | function onload(event) { 8 | initWebSocket(); 9 | } 10 | 11 | function getReadings(){ 12 | websocket.send("getReadings"); 13 | } 14 | 15 | function initWebSocket() { 16 | console.log('Trying to open a WebSocket connection…'); 17 | websocket = new WebSocket(gateway); 18 | websocket.onopen = onOpen; 19 | websocket.onclose = onClose; 20 | websocket.onmessage = onMessage; 21 | } 22 | 23 | // When websocket is established, call the getReadings() function 24 | function onOpen(event) { 25 | console.log('Connection opened'); 26 | getReadings(); 27 | } 28 | 29 | function onClose(event) { 30 | console.log('Connection closed'); 31 | setTimeout(initWebSocket, 2000); 32 | } 33 | 34 | // Function that receives the message from the ESP32 with the readings 35 | function onMessage(event) { 36 | console.log(event.data); 37 | var myObj = JSON.parse(event.data); 38 | var keys = Object.keys(myObj); 39 | 40 | for (var i = 0; i < keys.length; i++){ 41 | var key = keys[i]; 42 | document.getElementById(key).innerHTML = myObj[key]; 43 | } 44 | } -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Sensor_Readings_WebSocket/data/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: Arial, Helvetica, sans-serif; 3 | display: inline-block; 4 | text-align: center; 5 | } 6 | h1 { 7 | font-size: 1.8rem; 8 | color: white; 9 | } 10 | .topnav { 11 | overflow: hidden; 12 | background-color: #0A1128; 13 | } 14 | body { 15 | margin: 0; 16 | } 17 | .content { 18 | padding: 50px; 19 | } 20 | .card-grid { 21 | max-width: 800px; 22 | margin: 0 auto; 23 | display: grid; 24 | grid-gap: 2rem; 25 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 26 | } 27 | .card { 28 | background-color: white; 29 | box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); 30 | } 31 | .card-title { 32 | font-size: 1.2rem; 33 | font-weight: bold; 34 | color: #034078; 35 | } 36 | .reading { 37 | font-size: 1.2rem; 38 | color: #1282A2; 39 | } 40 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Stepper_Motor_Websocket/ESP8266_Stepper_Motor_Websocket.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Stepper_Motor_Websocket/ESP8266_Stepper_Motor_Websocket.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Stepper_Motor_Websocket/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_Stepper_Motor_Websocket/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_Thermocouple.ino: -------------------------------------------------------------------------------- 1 | // this example is public domain. enjoy! https://learn.adafruit.com/thermocouple/ 2 | 3 | #include "max6675.h" 4 | 5 | int thermoDO = 12; 6 | int thermoCS = 15; 7 | int thermoCLK = 14; 8 | 9 | MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | 14 | Serial.println("MAX6675 test"); 15 | // wait for MAX chip to stabilize 16 | delay(500); 17 | } 18 | 19 | void loop() { 20 | // basic readout test, just print the current temp 21 | 22 | Serial.print("C = "); 23 | Serial.println(thermocouple.readCelsius()); 24 | Serial.print("F = "); 25 | Serial.println(thermocouple.readFahrenheit()); 26 | 27 | // For the MAX6675 to update, you must delay AT LEAST 250ms between reads! 28 | delay(1000); 29 | } 30 | -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_WiFi_Manager/ESP8266_WiFi_Manager.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_WiFi_Manager/ESP8266_WiFi_Manager.zip -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_WiFi_Manager/data/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/ESP8266/ESP8266_WiFi_Manager/data/favicon.png -------------------------------------------------------------------------------- /Projects/ESP8266/ESP8266_WiFi_Manager/data/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ESP WEB SERVER 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

ESP WEB SERVER

13 |
14 |
15 |
16 |
17 |

GPIO 2

18 |

19 | 20 | 21 |

22 |

State: %STATE%

23 |
24 |
25 |
26 | 27 | -------------------------------------------------------------------------------- /Projects/ESP8266/VS_Code/VS_Code_LittleFS_Test.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp8266-nodemcu-vs-code-platformio-littlefs/ 4 | *********/ 5 | 6 | #include 7 | #include "LittleFS.h" 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | 12 | if(!LittleFS.begin()){ 13 | Serial.println("An Error has occurred while mounting LittleFS"); 14 | return; 15 | } 16 | 17 | File file = LittleFS.open("/text.txt", "r"); 18 | if(!file){ 19 | Serial.println("Failed to open file for reading"); 20 | return; 21 | } 22 | 23 | Serial.println("File Content:"); 24 | while(file.available()){ 25 | Serial.write(file.read()); 26 | } 27 | file.close(); 28 | } 29 | 30 | void loop() { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Projects/ESP8266/blink.lua: -------------------------------------------------------------------------------- 1 | lighton=0 2 | pin=4 3 | gpio.mode(pin,gpio.OUTPUT) 4 | tmr.alarm(1,2000,1,function() 5 | if lighton==0 then 6 | lighton=1 7 | gpio.write(pin,gpio.HIGH) 8 | else 9 | lighton=0 10 | gpio.write(pin,gpio.LOW) 11 | end 12 | end) 13 | -------------------------------------------------------------------------------- /Projects/ESP8266/email_notifier_ifttt.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos 2 | -- Complete project details at http://randomnerdtutorials.com 3 | 4 | wifi.setmode(wifi.STATION) 5 | wifi.sta.config("YOUR_NETWORK_NAME","YOUR_NETWORK_PASSWORD") 6 | pin = 4 7 | gpio.mode(pin, gpio.INT) 8 | 9 | function onChange () 10 | -- A simple http client 11 | print('Motion Detected') 12 | conn = nil 13 | conn=net.createConnection(net.TCP, 0) 14 | conn:on("receive", function(conn, payload) end) 15 | conn:connect(80,"maker.ifttt.com") 16 | conn:on("connection", function(conn, payload) 17 | conn:send("POST /trigger/motion_detected/with/key/YOUR_API_KEY HTTP/1.1\r\nHost: maker.ifttt.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") end) 18 | conn:close() 19 | print('Email Sent') 20 | end 21 | gpio.trig(pin, 'up', onChange) 22 | -------------------------------------------------------------------------------- /Projects/ESP8266/emaill_notifier.lua: -------------------------------------------------------------------------------- 1 | wifi.setmode(wifi.STATION) 2 | wifi.sta.config("YOUR_NETWORK_NAME","YOUR_NETWORK_PASSWORD") 3 | pin = 4 4 | gpio.mode(pin, gpio.INT) 5 | 6 | function onChange () 7 | -- A simple http client 8 | print('Motion Detected') 9 | conn = nil 10 | conn=net.createConnection(net.TCP, 0) 11 | conn:on("receive", function(conn, payload) end) 12 | conn:connect(80,"api.thingspeak.com") 13 | conn:on("connection", function(conn, payload) 14 | conn:send("POST /apps/thinghttp/send_request?api_key=YOUR_API_KEY HTTP/1.1\r\nHost: api.thingspeak.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") end) 15 | conn:close() 16 | print('Email Sent') 17 | end 18 | gpio.trig(pin, 'up', onChange) 19 | -------------------------------------------------------------------------------- /Projects/ESPEasy/Sonoff_and_Node_RED.txt: -------------------------------------------------------------------------------- 1 | [{"id":"7d1b5d27.edb2a4","type":"http request","z":"edbc86db.6e9fb8","name":"HTTP GET On","method":"GET","ret":"txt","url":"192.168.1.113/control?cmd=GPIO,12,1","tls":"","x":887.5,"y":328,"wires":[[]]},{"id":"394ffaed.da53a6","type":"ui_switch","z":"edbc86db.6e9fb8","name":"SONOFF Switch","label":"SONOFF Switch","group":"12bfe4c6.75164b","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":498,"y":367,"wires":[["c7dd35a9.81d208"]]},{"id":"c7dd35a9.81d208","type":"switch","z":"edbc86db.6e9fb8","name":"Switch On or Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","outputs":2,"x":683,"y":367,"wires":[["7d1b5d27.edb2a4"],["25b13354.e4769c"]]},{"id":"25b13354.e4769c","type":"http request","z":"edbc86db.6e9fb8","name":"HTTP GET Off","method":"GET","ret":"txt","url":"192.168.1.113/control?cmd=GPIO,12,0","tls":"","x":886,"y":403,"wires":[[]]},{"id":"12bfe4c6.75164b","type":"ui_group","z":"","name":"Outputs","tab":"e79509a5.8550c8","order":1,"disp":true,"width":"6"},{"id":"e79509a5.8550c8","type":"ui_tab","z":"","name":"Office","icon":"dashboard","order":1}] 2 | -------------------------------------------------------------------------------- /Projects/GSM/makePhoneCall.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Complete project details at http://randomnerdtutorials.com 3 | *********/ 4 | 5 | #include 6 | 7 | // Configure software serial port 8 | SoftwareSerial SIM900(7, 8); 9 | 10 | void setup() { 11 | // Arduino communicates with SIM900 GSM shield at a baud rate of 19200 12 | // Make sure that corresponds to the baud rate of your module 13 | SIM900.begin(19200); 14 | // Give time to your GSM shield log on to network 15 | delay(20000); 16 | 17 | // Make the phone call 18 | callSomeone(); 19 | } 20 | 21 | void loop() { 22 | 23 | } 24 | 25 | void callSomeone() { 26 | // REPLACE THE X's WITH THE NUMER YOU WANT TO DIAL 27 | // USE INTERNATIONAL FORMAT CODE FOR MOBILE NUMBERS 28 | SIM900.println("ATD + +XXXXXXXXX;"); 29 | delay(100); 30 | SIM900.println(); 31 | 32 | // In this example, the call only last 30 seconds 33 | // You can edit the phone call duration in the delay time 34 | delay(30000); 35 | // AT command to hang up 36 | SIM900.println("ATH"); // hang up 37 | } 38 | -------------------------------------------------------------------------------- /Projects/GSM/receiveSMS.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Complete project details at http://randomnerdtutorials.com 3 | *********/ 4 | 5 | #include 6 | 7 | // Configure software serial port 8 | SoftwareSerial SIM900(7, 8); 9 | //Variable to save incoming SMS characters 10 | char incoming_char=0; 11 | 12 | void setup() { 13 | // Arduino communicates with SIM900 GSM shield at a baud rate of 19200 14 | // Make sure that corresponds to the baud rate of your module 15 | SIM900.begin(19200); 16 | // For serial monitor 17 | Serial.begin(19200); 18 | // Give time to your GSM shield log on to network 19 | delay(20000); 20 | 21 | // AT command to set SIM900 to SMS mode 22 | SIM900.print("AT+CMGF=1\r"); 23 | delay(100); 24 | // Set module to send SMS data to serial out upon receipt 25 | SIM900.print("AT+CNMI=2,2,0,0,0\r"); 26 | delay(100); 27 | } 28 | 29 | void loop() { 30 | // Display any text that the GSM shield sends out on the serial monitor 31 | if(SIM900.available() >0) { 32 | //Get the character from the cellular serial port 33 | incoming_char=SIM900.read(); 34 | //Print the incoming character to the terminal 35 | Serial.print(incoming_char); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Projects/GSM/sendSMS.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Complete project details at http://randomnerdtutorials.com 3 | *********/ 4 | 5 | #include 6 | 7 | // Configure software serial port 8 | SoftwareSerial SIM900(7, 8); 9 | 10 | void setup() { 11 | // Arduino communicates with SIM900 GSM shield at a baud rate of 19200 12 | // Make sure that corresponds to the baud rate of your module 13 | SIM900.begin(19200); 14 | // Give time to your GSM shield log on to network 15 | delay(20000); 16 | 17 | // Send the SMS 18 | sendSMS(); 19 | } 20 | 21 | void loop() { 22 | 23 | } 24 | 25 | void sendSMS() { 26 | // AT command to set SIM900 to SMS mode 27 | SIM900.print("AT+CMGF=1\r"); 28 | delay(100); 29 | 30 | // REPLACE THE X's WITH THE RECIPIENT'S MOBILE NUMBER 31 | // USE INTERNATIONAL FORMAT CODE FOR MOBILE NUMBERS 32 | SIM900.println("AT+CMGS=\"+XXXXXXXXXXXX\""); 33 | delay(100); 34 | 35 | // REPLACE WITH YOUR OWN SMS MESSAGE CONTENT 36 | SIM900.println("Message example from Arduino Uno."); 37 | delay(100); 38 | 39 | // End AT command with a ^Z, ASCII code 26 40 | SIM900.println((char)26); 41 | delay(100); 42 | SIM900.println(); 43 | // Give module time to send SMS 44 | delay(5000); 45 | } 46 | -------------------------------------------------------------------------------- /Projects/LCD_I2C/I2C_LCD_Display_Text.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://randomnerdtutorials.com 4 | *********/ 5 | 6 | #include 7 | 8 | // set the LCD number of columns and rows 9 | int lcdColumns = 16; 10 | int lcdRows = 2; 11 | 12 | // set LCD address, number of columns and rows 13 | // if you don't know your display address, run an I2C scanner sketch 14 | LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows); 15 | 16 | void setup(){ 17 | // initialize LCD 18 | lcd.init(); 19 | // turn on LCD backlight 20 | lcd.backlight(); 21 | } 22 | 23 | void loop(){ 24 | // set cursor to first column, first row 25 | lcd.setCursor(0, 0); 26 | // print message 27 | lcd.print("Hello, World!"); 28 | delay(1000); 29 | // clears the display to print new message 30 | lcd.clear(); 31 | // set cursor to first column, second row 32 | lcd.setCursor(0,1); 33 | lcd.print("Hello, World!"); 34 | delay(1000); 35 | lcd.clear(); 36 | } 37 | -------------------------------------------------------------------------------- /Projects/LCD_I2C/I2C_Scanner.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://randomnerdtutorials.com 4 | *********/ 5 | 6 | #include 7 | 8 | void setup() { 9 | Wire.begin(); 10 | Serial.begin(115200); 11 | Serial.println("\nI2C Scanner"); 12 | } 13 | 14 | void loop() { 15 | byte error, address; 16 | int nDevices; 17 | Serial.println("Scanning..."); 18 | nDevices = 0; 19 | for(address = 1; address < 127; address++ ) { 20 | Wire.beginTransmission(address); 21 | error = Wire.endTransmission(); 22 | if (error == 0) { 23 | Serial.print("I2C device found at address 0x"); 24 | if (address<16) { 25 | Serial.print("0"); 26 | } 27 | Serial.println(address,HEX); 28 | nDevices++; 29 | } 30 | else if (error==4) { 31 | Serial.print("Unknow error at address 0x"); 32 | if (address<16) { 33 | Serial.print("0"); 34 | } 35 | Serial.println(address,HEX); 36 | } 37 | } 38 | if (nDevices == 0) { 39 | Serial.println("No I2C devices found\n"); 40 | } 41 | else { 42 | Serial.println("done\n"); 43 | } 44 | delay(5000); 45 | } 46 | -------------------------------------------------------------------------------- /Projects/MIT-App-Inventor/Arduino_Bluetooth_DC_Motors.aia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/MIT-App-Inventor/Arduino_Bluetooth_DC_Motors.aia -------------------------------------------------------------------------------- /Projects/MIT-App-Inventor/Arduino_Bluetooth_DC_Motors.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/MIT-App-Inventor/Arduino_Bluetooth_DC_Motors.apk -------------------------------------------------------------------------------- /Projects/MIT-App-Inventor/Control_RGB_LED.aia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/MIT-App-Inventor/Control_RGB_LED.aia -------------------------------------------------------------------------------- /Projects/MIT-App-Inventor/Control_RGB_LED.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/MIT-App-Inventor/Control_RGB_LED.apk -------------------------------------------------------------------------------- /Projects/Magnetic_Contact_Switch.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Created by Rui Santos 4 | 5 | All the resources for this project: 6 | http://randomnerdtutorials.com/ 7 | 8 | */ 9 | 10 | int ledOpen=8; 11 | int ledClose=10; 12 | int switchReed=6; 13 | 14 | void setup(){ 15 | pinMode(ledOpen, OUTPUT); 16 | pinMode(ledClose, OUTPUT); 17 | pinMode(switchReed, INPUT); 18 | Serial.begin(9600); 19 | } 20 | 21 | void loop(){ 22 | 23 | if (digitalRead(switchReed)==HIGH){ 24 | digitalWrite(ledOpen, LOW); 25 | digitalWrite(ledClose, HIGH); 26 | Serial.println("Your Door is Closed"); 27 | } 28 | else { 29 | digitalWrite(ledOpen, HIGH); 30 | digitalWrite(ledClose, LOW); 31 | Serial.println("Your Door is Open"); 32 | } 33 | delay(1); 34 | } 35 | -------------------------------------------------------------------------------- /Projects/Nextion_28_Project_Example/Nextion_28_Project.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/Nextion_28_Project_Example/Nextion_28_Project.HMI -------------------------------------------------------------------------------- /Projects/Nextion_28_Project_Example/Nextion_28_Project.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/Nextion_28_Project_Example/Nextion_28_Project.tft -------------------------------------------------------------------------------- /Projects/Nextion_28_Project_Example/background_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/Nextion_28_Project_Example/background_blue.png -------------------------------------------------------------------------------- /Projects/OLED/oled_hello_world.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://randomnerdtutorials.com 4 | *********/ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define SCREEN_WIDTH 128 // OLED display width, in pixels 11 | #define SCREEN_HEIGHT 64 // OLED display height, in pixels 12 | 13 | // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) 14 | Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); 15 | 16 | void setup() { 17 | Serial.begin(115200); 18 | 19 | if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64 20 | Serial.println(F("SSD1306 allocation failed")); 21 | for(;;); 22 | } 23 | delay(2000); 24 | display.clearDisplay(); 25 | 26 | display.setTextSize(1); 27 | display.setTextColor(WHITE); 28 | display.setCursor(0, 10); 29 | // Display static text 30 | display.println("Hello, world!"); 31 | display.display(); 32 | } 33 | 34 | void loop() { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Projects/OLED/oled_set_different_fonts.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://randomnerdtutorials.com 4 | *********/ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define SCREEN_WIDTH 128 // OLED display width, in pixels 12 | #define SCREEN_HEIGHT 64 // OLED display height, in pixels 13 | 14 | // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) 15 | Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); 16 | 17 | void setup() { 18 | Serial.begin(115200); 19 | 20 | if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 21 | Serial.println("SSD1306 allocation failed"); 22 | for(;;); 23 | } 24 | delay(2000); 25 | 26 | display.setFont(&FreeSerif9pt7b); 27 | display.clearDisplay(); 28 | display.setTextSize(1); 29 | display.setTextColor(WHITE); 30 | display.setCursor(0,20); 31 | display.println("Hello, world!"); 32 | display.display(); 33 | delay(2000); 34 | } 35 | void loop() { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Projects/PiCamera/record_video.py: -------------------------------------------------------------------------------- 1 | import picamera 2 | 3 | camera = picamera.PiCamera() 4 | 5 | camera.resolution = (640, 480) 6 | camera.start_recording('test_video.h264') 7 | camera.wait_recording(5) 8 | camera.stop_recording() 9 | 10 | print('Finished recording') 11 | -------------------------------------------------------------------------------- /Projects/PiCamera/take_photo.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | from picamera import PiCamera 3 | 4 | camera = PiCamera() 5 | camera.resolution = (1024, 768) 6 | camera.start_preview() 7 | 8 | sleep(2) 9 | camera.capture('test_photo.jpg') 10 | -------------------------------------------------------------------------------- /Projects/Post_Tweet_ESP8266.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos 2 | -- Complete project details at http://randomnerdtutorials.com 3 | 4 | wifi.setmode(wifi.STATION) 5 | wifi.sta.config("YOUR_NETWORK_NAME","YOUR_NETWORK_PASSWORD") 6 | 7 | -- A simple http client 8 | conn = nil 9 | conn=net.createConnection(net.TCP, 0) 10 | conn:on("receive", function(conn, payload) end) 11 | conn:connect(80,"maker.ifttt.com") 12 | conn:on("connection", function(conn, payload) 13 | conn:send("POST /trigger/post_tweet/with/key/YOUR_API_KEY HTTP/1.1\r\nHost: maker.ifttt.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") end) 14 | conn:close() 15 | print('Posted Tweet') 16 | -------------------------------------------------------------------------------- /Projects/Post_Tweet_ESP8266_Contains_Data.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos 2 | -- Complete project details at http://randomnerdtutorials.com 3 | 4 | wifi.setmode(wifi.STATION) 5 | wifi.sta.config("YOUR_NETWORK_NAME","YOUR_NETWORK_PASSWORD") 6 | 7 | -- A simple http client 8 | conn = nil 9 | conn=net.createConnection(net.TCP, 0) 10 | conn:on("receive", function(conn, payload) end) 11 | conn:connect(80,"maker.ifttt.com") 12 | conn:on("connection", function(conn, payload) 13 | conn:send("POST /trigger/post_tweet/with/key/YOUR_API_KEY HTTP/1.1\r\n".. 14 | "Host: maker.ifttt.com\r\nConnection: close\r\nAccept: */*\r\nContent-Type: application/json\r\n" .. 15 | "Content-Length: 17\r\n\r\n{\"value1\":true}\r\n") end) 16 | conn:close() 17 | print('Posted Tweet') 18 | -------------------------------------------------------------------------------- /Projects/Power_Latch_Circuit.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://randomnerdtutorials.com 4 | *********/ 5 | 6 | // Define power latch pin for ESP32 (GPIO 5) / ESP8266 (GPIO 5) / Arduino (Digital 5) 7 | const int powerLatch = 5; 8 | 9 | void setup() { 10 | // Define pin as an OUTPUT 11 | pinMode(powerLatch, OUTPUT); 12 | 13 | // Keeps the circuit on 14 | digitalWrite(powerLatch, HIGH); 15 | // Waits for 10 seconds 16 | delay(10000); 17 | // Turns the power latch circuit off 18 | digitalWrite(powerLatch, LOW); 19 | } 20 | 21 | void loop() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Projects/RPi_Keyboard_Example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | NULL_CHAR = chr(0) 3 | 4 | def write_report(report): 5 | with open('/dev/hidg0', 'rb+') as fd: 6 | fd.write(report.encode()) 7 | 8 | # Press a 9 | write_report(NULL_CHAR*2+chr(4)+NULL_CHAR*5) 10 | # Release keys 11 | write_report(NULL_CHAR*8) 12 | # Press SHIFT + a = A 13 | write_report(chr(32)+NULL_CHAR+chr(4)+NULL_CHAR*5) 14 | 15 | # Press b 16 | write_report(NULL_CHAR*2+chr(5)+NULL_CHAR*5) 17 | # Release keys 18 | write_report(NULL_CHAR*8) 19 | # Press SHIFT + b = B 20 | write_report(chr(32)+NULL_CHAR+chr(5)+NULL_CHAR*5) 21 | 22 | # Press SPACE key 23 | write_report(NULL_CHAR*2+chr(44)+NULL_CHAR*5) 24 | 25 | # Press c key 26 | write_report(NULL_CHAR*2+chr(6)+NULL_CHAR*5) 27 | # Press d key 28 | write_report(NULL_CHAR*2+chr(7)+NULL_CHAR*5) 29 | 30 | # Press RETURN/ENTER key 31 | write_report(NULL_CHAR*2+chr(40)+NULL_CHAR*5) 32 | 33 | # Press e key 34 | write_report(NULL_CHAR*2+chr(8)+NULL_CHAR*5) 35 | # Press f key 36 | write_report(NULL_CHAR*2+chr(9)+NULL_CHAR*5) 37 | 38 | # Release all keys 39 | write_report(NULL_CHAR*8) 40 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/Arduino/AnalogRead_Potentiometer.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-analog-inputs-arduino/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | *********/ 8 | 9 | // Potentiometer is connected to GPIO 26 (Analog ADC0) 10 | const int potPin = 26; 11 | 12 | // variable for storing the potentiometer value 13 | int potValue = 0; 14 | 15 | void setup() { 16 | Serial.begin(115200); 17 | analogReadResolution(12); 18 | delay(1000); 19 | } 20 | 21 | void loop() { 22 | // Reading potentiometer value 23 | potValue = analogRead(potPin); 24 | Serial.println(potValue); 25 | delay(500); 26 | } 27 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/Arduino/DS18B20_Get_Sensor_Address.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-ds18b20-arduino/ 4 | 5 | Example from the library microSD18B20.h: https://github.com/GyverLibs/microDS18B20/tree/main/examples 6 | Get the address of DS18B20 sensor (one sensor connected at a time) 7 | *********/ 8 | 9 | #include 10 | 11 | // We're using GPIO 22, change accordingly 12 | MicroDS18B20 <22> sensor; 13 | 14 | // Array to store the sensor address 15 | uint8_t address[8]; 16 | 17 | void setup() { 18 | Serial.begin(115200); 19 | } 20 | 21 | void loop() { 22 | if (sensor.readAddress(address)) { 23 | Serial.print('{'); 24 | for (uint8_t i = 0; i < 8; i++) { 25 | Serial.print("0x"); 26 | Serial.print(address[i], HEX); 27 | if (i < 7) Serial.print(", "); 28 | } 29 | Serial.println('}'); 30 | 31 | } else Serial.println("Not connected"); 32 | delay(1000); 33 | } 34 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/Arduino/DS18B20_Single.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-ds18b20-arduino/ 4 | 5 | Example adapted from the microDS18B20 library examples folder - microSD18B20 library: https://github.com/GyverLibs/microDS18B20 6 | *********/ 7 | 8 | #include 9 | 10 | // We're using GPIO 22, change accordingly 11 | MicroDS18B20<22> sensor; 12 | 13 | void setup() { 14 | Serial.begin(115200); 15 | } 16 | 17 | void loop() { 18 | //request temperature from sensor 19 | sensor.requestTemp(); 20 | 21 | delay(1000); 22 | 23 | //print the temperature 24 | Serial.print("Temperature (ºC): "); 25 | Serial.println(sensor.getTemp()); 26 | 27 | //Temperature in Fahrenheit 28 | //Serial.print("Temperature (ºF): "); 29 | //Serial.println(sensor.getTemp()*(9.0/5.0) + 32.0); 30 | } 31 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/Arduino/Pico_Internal_Temperature_Sensor.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos & Sara Santos - Random Nerd Tutorials 3 | Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-internal-temperature-arduino/ 4 | *********/ 5 | 6 | float tempC; 7 | float tempF; 8 | 9 | void setup() { 10 | Serial.begin(115200); 11 | } 12 | 13 | void loop() { 14 | tempC = analogReadTemp(); // Get internal temperature 15 | tempF = tempC * 9.0 / 5.0 + 32.0; // Fahrenheit conversion 16 | Serial.print("Temperature Celsius (ºC): "); 17 | Serial.println(tempC); 18 | Serial.print("Temperature Fahrenheit (ºF): "); 19 | Serial.println(tempF); 20 | delay(1000); 21 | } 22 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/BH1750_Basic.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-bh1750-micropython/ 3 | 4 | from machine import Pin, SoftI2C 5 | from bh1750 import BH1750 6 | import time 7 | 8 | # Initialize I2C communication 9 | i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=400000) 10 | 11 | # Create BH1750 object 12 | light_sensor = BH1750(bus=i2c, addr=0x23) 13 | 14 | try: 15 | # Read lux every 2 seconds 16 | while True: 17 | lux = light_sensor.luminance(BH1750.CONT_HIRES_1) 18 | print("Luminance: {:.2f} lux".format(lux)) 19 | time.sleep(2) 20 | 21 | except Exception as e: 22 | # Handle any exceptions during sensor reading 23 | print("An error occurred:", e) 24 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/BME680_Basic.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details: https://RandomNerdTutorials.com/raspberry-pi-pico-bme680-micropython/ 3 | 4 | from machine import Pin, I2C 5 | from time import sleep 6 | from bme680 import * 7 | 8 | # RPi Pico - Pin assignment 9 | i2c = I2C(id=0, scl=Pin(5), sda=Pin(4)) 10 | 11 | bme = BME680_I2C(i2c=i2c) 12 | 13 | while True: 14 | try: 15 | temp = str(round(bme.temperature, 2)) + ' C' 16 | #temp = (bme.temperature) * (9/5) + 32 17 | #temp = str(round(temp, 2)) + 'F' 18 | 19 | hum = str(round(bme.humidity, 2)) + ' %' 20 | 21 | pres = str(round(bme.pressure, 2)) + ' hPa' 22 | 23 | gas = str(round(bme.gas/1000, 2)) + ' KOhms' 24 | 25 | print('Temperature:', temp) 26 | print('Humidity:', hum) 27 | print('Pressure:', pres) 28 | print('Gas:', gas) 29 | print('-------') 30 | except OSError as e: 31 | print('Failed to read sensor.') 32 | 33 | sleep(5) 34 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Connect_to_Wi-Fi.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-w-wi-fi-micropython/ 3 | 4 | import network 5 | from time import sleep 6 | # Wi-Fi credentials 7 | ssid = 'REPLACE_WITH_YOUR_SSID' 8 | password = 'REPLACE_WITH_YOUR_PASSWORD' 9 | 10 | # Init Wi-Fi Interface 11 | wlan = network.WLAN(network.STA_IF) 12 | wlan.active(True) 13 | 14 | # Connect to your network 15 | wlan.connect(ssid, password) 16 | 17 | # Wait for Wi-Fi connection 18 | connection_timeout = 10 19 | while connection_timeout > 0: 20 | if wlan.status() >= 3: 21 | break 22 | connection_timeout -= 1 23 | print('Waiting for Wi-Fi connection...') 24 | sleep(1) 25 | 26 | # Check if connection is successful 27 | if wlan.status() != 3: 28 | raise RuntimeError('Failed to establish a network connection') 29 | else: 30 | print('Connection successful!') 31 | network_info = wlan.ifconfig() 32 | print('IP address:', network_info[0]) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Control_DC_Motor.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-dc-motor-micropython/ 3 | 4 | from dcmotor import DCMotor 5 | from machine import Pin, PWM 6 | from time import sleep 7 | 8 | frequency = 1000 9 | 10 | pin1 = Pin(3, Pin.OUT) 11 | pin2 = Pin(4, Pin.OUT) 12 | enable = PWM(Pin(2), frequency) 13 | 14 | dc_motor = DCMotor(pin1, pin2, enable) 15 | 16 | # Set min duty cycle (15000) and max duty cycle (65535) 17 | #dc_motor = DCMotor(pin1, pin2, enable, 15000, 65535) 18 | 19 | try: 20 | print('Forward with speed: 50%') 21 | dc_motor.forward(50) 22 | sleep(5) 23 | dc_motor.stop() 24 | sleep(5) 25 | print('Backwards with speed: 100%') 26 | dc_motor.backwards(100) 27 | sleep(5) 28 | print('Forward with speed: 5%') 29 | dc_motor.forward(5) 30 | sleep(5) 31 | dc_motor.stop() 32 | 33 | except KeyboardInterrupt: 34 | print('Keyboard Interrupt') 35 | dc_motor.stop() 36 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Control_Servo_Motor_Module.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-servo-motor-micropython/ 3 | 4 | from servo import Servo 5 | from time import sleep 6 | 7 | # Create a Servo object on pin 0 8 | servo=Servo(pin=0) 9 | 10 | try: 11 | while True: 12 | #Servo at 0 degrees 13 | servo.move(0) 14 | sleep(2) 15 | #Servo at 90 degrees 16 | servo.move(90) 17 | sleep(2) 18 | #Servo at 180 degrees 19 | servo.move(180) 20 | sleep(2) 21 | 22 | except KeyboardInterrupt: 23 | print("Keyboard interrupt") 24 | # Turn off PWM 25 | servo.stop() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Control_Servo_Motor_PWM.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-servo-motor-micropython/ 3 | 4 | from machine import Pin, PWM 5 | from time import sleep 6 | 7 | # Set up PWM Pin for servo control 8 | servo_pin = machine.Pin(0) 9 | servo = PWM(servo_pin) 10 | 11 | # Set Duty Cycle for Different Angles 12 | max_duty = 7864 13 | min_duty = 1802 14 | half_duty = int(max_duty/2) 15 | 16 | #Set PWM frequency 17 | frequency = 50 18 | servo.freq (frequency) 19 | 20 | try: 21 | while True: 22 | #Servo at 0 degrees 23 | servo.duty_u16(min_duty) 24 | sleep(2) 25 | #Servo at 90 degrees 26 | servo.duty_u16(half_duty) 27 | sleep(2) 28 | #Servo at 180 degrees 29 | servo.duty_u16(max_duty) 30 | sleep(2) 31 | 32 | except KeyboardInterrupt: 33 | print("Keyboard interrupt") 34 | # Turn off PWM 35 | servo.deinit() 36 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/HTTP_Request_Basic.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details: https://RandomNerdTutorials.com/raspberry-pi-pico-w-http-requests-micropython/ 3 | 4 | import network 5 | import requests 6 | 7 | # Wi-Fi credentials 8 | ssid = 'REPLACE_WITH_YOUR_SSID' 9 | password = 'REPLACE_WITH_YOUR_PASSWORD' 10 | 11 | # Connect to network 12 | wlan = network.WLAN(network.STA_IF) 13 | wlan.active(True) 14 | 15 | # Connect to your network 16 | wlan.connect(ssid, password) 17 | 18 | # Make GET request 19 | response = requests.get("http://www.google.com") 20 | # Get response code 21 | response_code = response.status_code 22 | # Get response content 23 | response_content = response.content 24 | 25 | # Print results 26 | print('Response code: ', response_code) 27 | print('Response content:', response_content) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/I2C_Scanner.py: -------------------------------------------------------------------------------- 1 | # I2C Scanner MicroPython 2 | from machine import Pin, SoftI2C 3 | 4 | # You can choose any other combination of I2C pins 5 | i2c = SoftI2C(scl=Pin(5), sda=Pin(4)) 6 | 7 | print('I2C SCANNER') 8 | devices = i2c.scan() 9 | 10 | if len(devices) == 0: 11 | print("No i2c device !") 12 | else: 13 | print('i2c devices found:', len(devices)) 14 | 15 | for device in devices: 16 | print("I2C hexadecimal address: ", hex(device)) 17 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Internal_Temperature_Sensor_picozero.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-internal-temperature-micropython/ 3 | 4 | from picozero import pico_temp_sensor 5 | 6 | # Convert from celsius to fahrenheit 7 | def celsius_to_fahrenheit(temp_celsius): 8 | temp_fahrenheit = temp_celsius * (9/5) + 32 9 | return temp_fahrenheit 10 | 11 | # Reading and printing the internal temperature 12 | temperatureC = pico_temp_sensor.temp 13 | temperatureF = celsius_to_fahrenheit(temperatureC) 14 | 15 | print("Internal Temperature:", temperatureC, "°C") 16 | print("Internal Temperature:", temperatureF, "°F") 17 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Internal_Temperature_Sensor_picozero_loop.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-internal-temperature-micropython/ 3 | 4 | from time import sleep 5 | from picozero import pico_temp_sensor 6 | 7 | # Convert from celsius to fahrenheit 8 | def celsius_to_fahrenheit(temp_celsius): 9 | temp_fahrenheit = temp_celsius * (9/5) + 32 10 | return temp_fahrenheit 11 | 12 | while True: 13 | # Reading and printing the internal temperature 14 | temperatureC = pico_temp_sensor.temp 15 | temperatureF = celsius_to_fahrenheit(temperatureC) 16 | 17 | print("Internal Temperature:", temperatureC, "°C") 18 | print("Internal Temperature:", temperatureF, "°F") 19 | 20 | # Wait one second between each reading 21 | sleep(1) 22 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/LDC_Display_Static_Text.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-i2c-lcd-display-micropython/ 3 | 4 | from machine import Pin, SoftI2C 5 | from pico_i2c_lcd import I2cLcd 6 | from time import sleep 7 | 8 | # Define the LCD I2C address and dimensions 9 | I2C_ADDR = 0x27 10 | I2C_NUM_ROWS = 2 11 | I2C_NUM_COLS = 16 12 | 13 | # Initialize I2C and LCD objects 14 | i2c = SoftI2C(sda=Pin(4), scl=Pin(5), freq=400000) 15 | lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS) 16 | 17 | lcd.putstr("It's working :)") 18 | sleep(4) 19 | 20 | try: 21 | while True: 22 | # Clear the LCD 23 | lcd.clear() 24 | # Display two different messages on different lines 25 | # By default, it will start at (0,0) if the display is empty 26 | lcd.putstr("Hello World!") 27 | sleep(2) 28 | lcd.clear() 29 | # Starting at the second line (0, 1) 30 | lcd.move_to(0, 1) 31 | lcd.putstr("Hello World!") 32 | sleep(2) 33 | 34 | except KeyboardInterrupt: 35 | # Turn off the display 36 | print("Keyboard interrupt") 37 | lcd.backlight_off() 38 | lcd.display_off() 39 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/NEO_6M_GPS_Raw_Data.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-neo-6m-micropython/ 3 | 4 | import machine 5 | from time import sleep 6 | 7 | # Define the UART pins and create a UART object 8 | gps_serial = machine.UART(1, baudrate=9600, tx=4, rx=5) 9 | 10 | while True: 11 | if gps_serial.any(): 12 | line = gps_serial.readline() # Read a complete line from the UART 13 | if line: 14 | line = line.decode('utf-8') 15 | print(line.strip()) 16 | sleep(0.5) 17 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/NEO_M8N_GPS_Raw_Data.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-neo-m8n-gps-micropython/ 3 | 4 | import machine 5 | from time import sleep 6 | 7 | # Define the UART pins and create a UART object 8 | gps_serial = machine.UART(1, baudrate=9600, tx=4, rx=5) 9 | 10 | while True: 11 | if gps_serial.any(): 12 | line = gps_serial.readline() # Read a complete line from the UART 13 | if line: 14 | line = line.decode('utf-8') 15 | print(line.strip()) 16 | sleep(0.5) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/PIR_Detect_Motion.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-motion-pir-micropython/ 3 | 4 | from machine import Pin 5 | from time import sleep 6 | 7 | pir_pin = Pin(22, Pin.IN) 8 | led_pin = Pin (21, Pin.OUT) 9 | 10 | while True: 11 | if pir_pin.value(): 12 | print("Motion detected!") 13 | led_pin.value(1) 14 | sleep(1) 15 | led_pin.value(0) 16 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Pico_Asynchronous_Programming.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/micropython-raspberry-pi-pico-asynchronous-programming/ 3 | 4 | import asyncio 5 | from machine import Pin 6 | 7 | green_led_pin = 20 8 | green_led = Pin(green_led_pin, Pin.OUT) 9 | blue_led_pin = 19 10 | blue_led = Pin(blue_led_pin, Pin.OUT) 11 | 12 | # Define coroutine function 13 | async def blink_green_led(): 14 | while True: 15 | green_led.toggle() 16 | await asyncio.sleep(2) 17 | 18 | # Define coroutine function 19 | async def blink_blue_led(): 20 | while True: 21 | blue_led.toggle() 22 | await asyncio.sleep(0.5) 23 | 24 | # Define the main function to run the event loop 25 | async def main(): 26 | # Create tasks for blinking two LEDs concurrently 27 | asyncio.create_task(blink_green_led()) 28 | asyncio.create_task(blink_blue_led()) 29 | 30 | # Create and run the event loop 31 | loop = asyncio.get_event_loop() 32 | loop.create_task(main()) # Create a task to run the main function 33 | loop.run_forever() # Run the event loop indefinitely 34 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Pico_Internal_Temperature_Sensor.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-internal-temperature-micropython/ 3 | 4 | from machine import ADC 5 | 6 | # Internal temperature sensor is connected to ADC channel 4 7 | temp_sensor = ADC(4) 8 | 9 | def read_internal_temperature(): 10 | # Read the raw ADC value 11 | adc_value = temp_sensor.read_u16() 12 | 13 | # Convert ADC value to voltage 14 | voltage = adc_value * (3.3 / 65535.0) 15 | 16 | # Temperature calculation based on sensor characteristics 17 | temperature_celsius = 27 - (voltage - 0.706) / 0.001721 18 | 19 | return temperature_celsius 20 | 21 | def celsius_to_fahrenheit(temp_celsius): 22 | temp_fahrenheit = temp_celsius * (9/5) + 32 23 | return temp_fahrenheit 24 | 25 | # Reading and printing the internal temperature 26 | temperatureC = read_internal_temperature() 27 | temperatureF = celsius_to_fahrenheit(temperatureC) 28 | print("Internal Temperature:", temperatureC, "°C") 29 | print("Internal Temperature:", temperatureF, "°F") 30 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Scan_Networks.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-w-wi-fi-micropython/ 3 | 4 | import network 5 | 6 | # Init Wi-Fi interface 7 | wlan = network.WLAN(network.STA_IF) 8 | wlan.active(True) 9 | 10 | # Scan for Wi-Fi networks 11 | networks = wlan.scan() 12 | 13 | # Print Wi-Fi networks 14 | print("Available WiFi Networks:") 15 | for network_info in networks: 16 | print(network_info) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Station_Access_Point_Interfaces.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-w-wi-fi-micropython/ 3 | 4 | import network 5 | 6 | sta_if = network.WLAN(network.STA_IF) 7 | print(sta_if.active()) 8 | 9 | ap_if = network.WLAN(network.AP_IF) 10 | print(ap_if.active()) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/Test_Micro_SD_Card.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-neo-m8n-gps-micropytho 3 | 4 | from machine import SPI, Pin 5 | import sdcard, os 6 | 7 | # Constants 8 | SPI_BUS = 0 9 | SCK_PIN = 18 10 | MOSI_PIN = 19 11 | MISO_PIN = 16 12 | CS_PIN = 17 13 | SD_MOUNT_PATH = '/sd' 14 | 15 | try: 16 | # Init SPI communication 17 | spi = SPI(SPI_BUS,sck=Pin(SCK_PIN), mosi=Pin(MOSI_PIN), miso=Pin(MISO_PIN)) 18 | cs = Pin(CS_PIN) 19 | sd = sdcard.SDCard(spi, cs) 20 | # Mount microSD card 21 | os.mount(sd, SD_MOUNT_PATH) 22 | # List files on the microSD card 23 | print(os.listdir(SD_MOUNT_PATH)) 24 | 25 | except Exception as e: 26 | print('An error occurred:', e) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/dcmotor.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-dc-motor-micropython/ 3 | 4 | class DCMotor: 5 | def __init__(self, pin1, pin2, enable_pin, min_duty=15000, max_duty=65535): 6 | self.pin1 = pin1 7 | self.pin2 = pin2 8 | self.enable_pin = enable_pin 9 | self.min_duty = min_duty 10 | self.max_duty = max_duty 11 | 12 | def forward(self, speed): 13 | self.speed = speed 14 | self.enable_pin.duty_u16(self.duty_cycle(self.speed)) 15 | self.pin1.value(1) 16 | self.pin2.value(0) 17 | 18 | def backwards(self, speed): 19 | self.speed = speed 20 | self.enable_pin.duty_u16(self.duty_cycle(self.speed)) 21 | self.pin1.value(0) 22 | self.pin2.value(1) 23 | 24 | def stop(self): 25 | self.enable_pin.duty_u16(0) 26 | self.pin1.value(0) 27 | self.pin2.value(0) 28 | 29 | def duty_cycle(self, speed): 30 | if speed <= 0 or speed > 100: 31 | duty_cycle = 0 32 | else: 33 | duty_cycle = int(self.min_duty + (self.max_duty - self.min_duty) * (speed / 100)) 34 | return duty_cycle 35 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/flash_nuke.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/7c644474e14ba27cdfa3d61f160a0b859052669e/Projects/Raspberry-Pi-Pico/MicroPython/flash_nuke.uf2 -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/interrupts/Blink_LED_Timer.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-interrupts-micropython/ 3 | 4 | from machine import Pin, Timer 5 | from time import sleep 6 | 7 | # LED pin 8 | led_pin = 20 9 | led = Pin(led_pin, Pin.OUT) 10 | 11 | # Callback function for the timer 12 | def toggle_led(timer): 13 | led.value(not led.value()) # Toggle the LED state (ON/OFF) 14 | 15 | # Create a periodic timer 16 | blink_timer = Timer() 17 | blink_timer.init(mode=Timer.PERIODIC, period=500, callback=toggle_led) # Timer repeats every half second 18 | 19 | # Main loop (optional) 20 | while True: 21 | print('Main Loop is running') 22 | sleep(2) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/interrupts/Multiple_LEDs_Timer.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-interrupts-micropython/ 3 | 4 | from machine import Pin, Timer 5 | from time import sleep 6 | 7 | # LEDs 8 | green_led_pin = 19 9 | green_led = Pin(green_led_pin, Pin.OUT) 10 | blue_led_pin = 20 11 | blue_led = Pin(blue_led_pin, Pin.OUT) 12 | 13 | # Callback function for the green timer 14 | def toggle_green_led(timer): 15 | green_led.toggle() # Toggle the LED state (ON/OFF) 16 | print('Green LED is: ', green_led.value()) 17 | 18 | # Callback function for the blue timer 19 | def toggle_blue_led(timer): 20 | blue_led.toggle() # Toggle the LED state (ON/OFF) 21 | print('Blue LED is: ', blue_led.value()) 22 | 23 | # Create periodic timers 24 | green_timer = Timer() 25 | blue_timer = Timer() 26 | 27 | # Init the timers 28 | green_timer.init(mode=Timer.PERIODIC, period=500, callback=toggle_green_led) # Timer repeats every 0.5 second 29 | blue_timer.init(mode=Timer.PERIODIC, period=2000, callback=toggle_blue_led) # Timer repeats every 2 seconds 30 | 31 | # Main loop (optional) 32 | while True: 33 | print('Main Loop is running') 34 | sleep(2) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/interrupts/Pushbutton_Counter_LED.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-interrupts-micropython/ 3 | 4 | from machine import Pin 5 | 6 | led = Pin(20, Pin.OUT) 7 | button = Pin(21, Pin.IN, Pin.PULL_DOWN) 8 | counter = 0 # Initialize the button press count 9 | 10 | def button_pressed(pin): 11 | global counter # Declare variable as global 12 | counter +=1 13 | print("Button Pressed! Count: ", counter) 14 | 15 | # Toggle the LED on each button press 16 | led.value(not led.value()) 17 | 18 | # Attach the interrupt to the button's rising edge 19 | button.irq(trigger=Pin.IRQ_RISING, handler=button_pressed) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/interrupts/Pushbutton_Debounce.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-interrupts-micropython/ 3 | 4 | from machine import Pin, Timer 5 | 6 | led = Pin(20, Pin.OUT) 7 | button = Pin(21, Pin.IN, Pin.PULL_DOWN) 8 | counter = 0 # Initialize the button press count 9 | debounce_timer = None 10 | 11 | def button_pressed(pin): 12 | global counter, debounce_timer # Declare variables as global 13 | 14 | if debounce_timer is None: 15 | counter += 1 16 | print("Button Pressed! Count: ", counter) 17 | 18 | # Toggle the LED on each button press 19 | led.toggle() 20 | 21 | # Start a timer for debounce period (e.g., 200 milliseconds) 22 | debounce_timer = Timer() 23 | debounce_timer.init(mode=Timer.ONE_SHOT, period=200, callback=debounce_callback) 24 | 25 | def debounce_callback(timer): 26 | global debounce_timer 27 | debounce_timer = None 28 | 29 | # Attach the interrupt to the button's rising edge 30 | button.irq(trigger=Pin.IRQ_RISING, handler=button_pressed) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/interrupts/Pushbutton_Interrupt.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-interrupts-micropython/ 3 | 4 | from machine import Pin 5 | 6 | button = Pin(21, Pin.IN, Pin.PULL_DOWN) 7 | 8 | def button_pressed(pin): 9 | print("Button Pressed!") 10 | 11 | # Attach the interrupt to the button's rising edge 12 | button.irq(trigger=Pin.IRQ_RISING, handler=button_pressed) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/interrupts/Pushbutton_Interrupt_Counter.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-interrupts-micropython/ 3 | 4 | from machine import Pin 5 | 6 | button = Pin(21, Pin.IN, Pin.PULL_DOWN) 7 | counter = 0 # Initialize the button press count 8 | 9 | def button_pressed(pin): 10 | global counter # Declare variable as global 11 | counter +=1 12 | print("Button Pressed! Count: ", counter) 13 | 14 | # Attach the interrupt to the button's rising edge 15 | button.irq(trigger=Pin.IRQ_RISING, handler=button_pressed) 16 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_Analog_Inputs_Potentiometer.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-analog-inputs-micropython/ 2 | from machine import Pin, ADC 3 | from time import sleep 4 | 5 | pot = ADC(Pin(26)) 6 | 7 | while True: 8 | pot_value = pot.read_u16() # read value, 0-65535 across voltage range 0.0v - 3.3v 9 | print(pot_value) 10 | sleep(0.1) 11 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_BME280_Basic.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-bme280-micropython/ 2 | 3 | from machine import Pin, I2C 4 | from time import sleep 5 | import BME280 6 | 7 | # Initialize I2C communication 8 | i2c = I2C(id=0, scl=Pin(5), sda=Pin(4), freq=10000) 9 | 10 | while True: 11 | try: 12 | # Initialize BME280 sensor 13 | bme = BME280.BME280(i2c=i2c) 14 | 15 | # Read sensor data 16 | tempC = bme.temperature 17 | hum = bme.humidity 18 | pres = bme.pressure 19 | 20 | # Convert temperature to fahrenheit 21 | tempF = (bme.read_temperature()/100) * (9/5) + 32 22 | tempF = str(round(tempF, 2)) + 'F' 23 | 24 | # Print sensor readings 25 | print('Temperature: ', tempC) 26 | print('Temperature: ', tempF) 27 | print('Humidity: ', hum) 28 | print('Pressure: ', pres) 29 | 30 | except Exception as e: 31 | # Handle any exceptions during sensor reading 32 | print('An error occurred:', e) 33 | 34 | sleep(5) 35 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_DS18B20_Multiple_Sensors_Addresses.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-ds18b20-micropython/ 2 | 3 | import machine, onewire, ds18x20, time 4 | 5 | ds_pin = machine.Pin(22) 6 | ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin)) 7 | 8 | roms = ds_sensor.scan() 9 | number_devices = len(roms) 10 | print('Number of found devices: ', number_devices) 11 | print('Adresses: ', roms) 12 | 13 | while True: 14 | ds_sensor.convert_temp() 15 | time.sleep_ms(750) 16 | for rom in roms: 17 | print(rom) 18 | 19 | tempC = ds_sensor.read_temp(rom) 20 | tempF = tempC * (9/5) +32 21 | 22 | print('temperature (ºC):', "{:.2f}".format(tempC)) 23 | print('temperature (ºF):', "{:.2f}".format(tempF)) 24 | print() 25 | 26 | time.sleep(5) 27 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_DS18B20_Single.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-ds18b20-micropython/ 2 | 3 | import machine, onewire, ds18x20, time 4 | 5 | ds_pin = machine.Pin(22) 6 | ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin)) 7 | 8 | roms = ds_sensor.scan() 9 | print('Found DS devices: ', roms) 10 | 11 | while True: 12 | ds_sensor.convert_temp() 13 | time.sleep_ms(750) 14 | for rom in roms: 15 | print(rom) 16 | tempC = ds_sensor.read_temp(rom) 17 | tempF = tempC * (9/5) +32 18 | print('temperature (ºC):', "{:.2f}".format(tempC)) 19 | print('temperature (ºF):', "{:.2f}".format(tempF)) 20 | print() 21 | time.sleep(5) 22 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_PWM_Fade_LED.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-pwm-micropython/ 2 | from machine import Pin, PWM 3 | from time import sleep 4 | 5 | # Set up PWM Pin 6 | led = machine.Pin(20) 7 | led_pwm = PWM(led) 8 | duty_step = 129 # Step size for changing the duty cycle 9 | 10 | #Set PWM frequency 11 | frequency = 5000 12 | led_pwm.freq (frequency) 13 | 14 | try: 15 | while True: 16 | # Increase the duty cycle gradually 17 | for duty_cycle in range(0, 65536, duty_step): 18 | led_pwm.duty_u16(duty_cycle) 19 | sleep(0.005) 20 | 21 | # Decrease the duty cycle gradually 22 | for duty_cycle in range(65536, 0, -duty_step): 23 | led_pwm.duty_u16(duty_cycle) 24 | sleep(0.005) 25 | 26 | except KeyboardInterrupt: 27 | print("Keyboard interrupt") 28 | led_pwm.duty_u16(0) 29 | print(led_pwm) 30 | led_pwm.deinit() 31 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_Pushbutton_LED_Inputs_Outputs.py: -------------------------------------------------------------------------------- 1 | # Rui Santos 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-outputs-inputs-micropython/ 3 | 4 | from machine import Pin 5 | from time import sleep 6 | 7 | led = Pin(20, Pin.OUT) 8 | button = Pin(21, Pin.IN, Pin.PULL_DOWN) 9 | 10 | while True: 11 | led.value(button.value()) 12 | sleep(0.1) 13 | print(button.value()) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_RCWL_0516_Basic.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-rcwl-0516-micropython/ 2 | 3 | from machine import Pin 4 | import time 5 | 6 | # Pin numbers for LED and sensor 7 | led_pin = 21 8 | sensor_pin = 22 9 | 10 | # Set the LED pin as an output and the sensor pin as an input 11 | led = Pin(led_pin, Pin.OUT) 12 | sensor = Pin(sensor_pin, Pin.IN) 13 | 14 | # Initialize state variables 15 | state = 0 16 | val = 0 17 | 18 | while True: 19 | val = sensor.value() # read sensor value 20 | 21 | if val == 1: # check if the sensor is HIGH 22 | led.on() # turn LED ON 23 | 24 | if state == 0: 25 | print("Motion detected!") 26 | state = 1 # update variable state to HIGH 27 | else: 28 | led.off() # turn LED OFF 29 | 30 | if state == 1: 31 | print("Motion stopped!") 32 | state = 0 # update variable state to LOW 33 | 34 | # Add a small delay to avoid constant checking of the sensor 35 | time.sleep(0.1) 36 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_Read_DHT_Sensor.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-dht11-dht22-micropython/ 2 | 3 | from machine import Pin 4 | from time import sleep 5 | import dht 6 | 7 | sensor = dht.DHT22(Pin(22)) 8 | #sensor = dht.DHT11(Pin(22)) 9 | 10 | while True: 11 | try: 12 | sleep(2) 13 | sensor.measure() 14 | temp = sensor.temperature() 15 | hum = sensor.humidity() 16 | temp_f = temp * (9/5) + 32.0 17 | print('Temperature: %3.1f C' %temp) 18 | print('Temperature: %3.1f F' %temp_f) 19 | print('Humidity: %3.1f %%' %hum) 20 | except OSError as e: 21 | print('Failed to read sensor.') 22 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/main_SSD1306_.Oled_Basic.py: -------------------------------------------------------------------------------- 1 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-ssd1306-oled-micropython/ 2 | 3 | from machine import Pin, SoftI2C 4 | import ssd1306 5 | 6 | #You can choose any other combination of I2C pins 7 | i2c = SoftI2C(scl=Pin(5), sda=Pin(4)) 8 | 9 | oled_width = 128 10 | oled_height = 64 11 | oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) 12 | 13 | oled.text('Hello, World 1!', 0, 0) 14 | oled.text('Hello, World 2!', 0, 10) 15 | oled.text('Hello, World 3!', 0, 20) 16 | 17 | oled.show() 18 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/mqtt/config.py: -------------------------------------------------------------------------------- 1 | wifi_ssid = 'REPLACE_WITH_YOUR_SSID' 2 | wifi_password = 'REPLACE_WITH_YOUR_PASSWORD' 3 | mqtt_server = b'MQTT_BROKER_URL' 4 | mqtt_username = b'BROKER_USERNAME' 5 | mqtt_password = b'BROKER_PASSWORD' 6 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi-Pico/MicroPython/sd_card/test_microsd_card.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-microsd-card-micropython/ 3 | 4 | from machine import SPI, Pin 5 | import sdcard, os 6 | 7 | # Constants 8 | SPI_BUS = 0 9 | SCK_PIN = 2 10 | MOSI_PIN = 3 11 | MISO_PIN = 4 12 | CS_PIN = 5 13 | SD_MOUNT_PATH = '/sd' 14 | 15 | try: 16 | # Init SPI communication 17 | spi = SPI(SPI_BUS,sck=Pin(SCK_PIN), mosi=Pin(MOSI_PIN), miso=Pin(MISO_PIN)) 18 | cs = Pin(CS_PIN) 19 | sd = sdcard.SDCard(spi, cs) 20 | # Mount microSD card 21 | os.mount(sd, SD_MOUNT_PATH) 22 | # List files on the microSD card 23 | print(os.listdir(SD_MOUNT_PATH)) 24 | 25 | except Exception as e: 26 | print('An error occurred:', e) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/OpenCV/opencv_test_usb_camera.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/set-up-usb-camera-opencv-raspberry-pi/ 3 | 4 | import cv2 5 | 6 | video_capture = cv2.VideoCapture(0) 7 | 8 | while True: 9 | result, video_frame = video_capture.read() # read frames from the video 10 | if result is False: 11 | break # terminate the loop if the frame is not read successfully 12 | 13 | cv2.imshow( 14 | "USB Camera Test", video_frame 15 | ) 16 | 17 | if cv2.waitKey(1) & 0xFF == ord("q"): 18 | break 19 | 20 | video_capture.release() 21 | cv2.destroyAllWindows() 22 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/blinking_led.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/projects-raspberry-pi/ 2 | 3 | from gpiozero import LED 4 | from time import sleep 5 | 6 | led = LED(14) 7 | 8 | # blinking an LED forever 9 | while True: 10 | #set the led ON for one second 11 | led.on() 12 | sleep(1) 13 | #set the led ON for one second 14 | led.off() 15 | sleep(1) 16 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/capture_video.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-picamera2-python/ 3 | 4 | from picamera2 import Picamera2 5 | 6 | picam2 = Picamera2() 7 | 8 | picam2.start_and_record_video("test_video.mp4", duration=5) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/control_outputs_based_on_time.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-control-outputs-based-on-time/ 2 | 3 | from gpiozero import LED, TimeOfDay 4 | from datetime import time 5 | from signal import pause 6 | 7 | led1 = LED(17) 8 | led2 = LED(27) 9 | 10 | tod1 = TimeOfDay(time(16,30), time(16,45), utc=False) 11 | tod2 = TimeOfDay(time(16,45), time(16,50), utc=False) 12 | 13 | tod1.when_activated = led1.on 14 | tod1.when_deactivated = led1.off 15 | 16 | tod2.when_activated = led2.on 17 | tod2.when_deactivated = led2.off 18 | 19 | pause() 20 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/control_outputs_based_on_time_conditions.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-control-outputs-based-on-time/ 2 | 3 | from gpiozero import LED, TimeOfDay 4 | from datetime import time 5 | from signal import pause 6 | 7 | led1 = LED(17) 8 | led2 = LED(27) 9 | 10 | tod1 = TimeOfDay(time(16,30), time(16,45), utc=False) 11 | tod2 = TimeOfDay(time(16,45), time(16,50), utc=False) 12 | 13 | while True: 14 | if tod1.is_active: 15 | led1.on() 16 | else: 17 | led1.off() 18 | 19 | if tod2.is_active: 20 | led2.on() 21 | else: 22 | led2.off() 23 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/dht_basic.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-dht11-dht22-python/ 2 | 3 | import Adafruit_DHT 4 | import time 5 | 6 | # comment and uncomment the lines below depending on your sensor 7 | sensor = Adafruit_DHT.DHT22 8 | # sensor = Adafruit_DHT.DHT11 9 | 10 | # DHT pin connects to GPIO 4 11 | sensor_pin = 4 12 | 13 | while True: 14 | humidity, temperature = Adafruit_DHT.read_retry(sensor, sensor_pin) # Use read_retry to retry in case of failure 15 | if humidity is not None and temperature is not None: 16 | # Uncomment the line below to convert to Fahrenheit 17 | temperatureF = temperature * 9/5.0 + 32 18 | print("Temp={0:0.1f}ºC, Temp={1:0.1f}ºF, Humidity={2:0.1f}%".format(temperature, temperatureF, humidity)) 19 | else: 20 | print("Sensor failure. Check wiring.") 21 | time.sleep(3) 22 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/ds18b20_basic.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-ds18b20-python/ 2 | 3 | # Based on the Adafruit example: https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_DS18B20_Temperature_Sensing/code.py 4 | 5 | import os 6 | import glob 7 | import time 8 | 9 | os.system('modprobe w1-gpio') 10 | os.system('modprobe w1-therm') 11 | 12 | base_dir = '/sys/bus/w1/devices/' 13 | device_folder = glob.glob(base_dir + '28*')[0] 14 | device_file = device_folder + '/w1_slave' 15 | 16 | def read_temp_raw(): 17 | f = open(device_file, 'r') 18 | lines = f.readlines() 19 | f.close() 20 | return lines 21 | 22 | def read_temp(): 23 | lines = read_temp_raw() 24 | while lines[0].strip()[-3:] != 'YES': 25 | time.sleep(0.2) 26 | lines = read_temp_raw() 27 | equals_pos = lines[1].find('t=') 28 | if equals_pos != -1: 29 | temp_string = lines[1][equals_pos+2:] 30 | temp_c = float(temp_string) / 1000.0 31 | temp_f = temp_c * 9.0 / 5.0 + 32.0 32 | return temp_c, temp_f 33 | while True: 34 | print(read_temp()) 35 | time.sleep(1) 36 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/inputs/digital_input_device.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-digital-inputs-python/ 2 | 3 | from gpiozero import DigitalInputDevice, LED 4 | 5 | led = LED(14) 6 | input = DigitalInputDevice(4) 7 | 8 | while True: 9 | if input.value: 10 | led.on() 11 | else: 12 | led.off() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/inputs/digital_input_device_events.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-digital-inputs-python/ 2 | 3 | from gpiozero import DigitalInputDevice, LED 4 | from signal import pause 5 | 6 | led = LED(14) 7 | input = DigitalInputDevice (4) 8 | 9 | print(input.value) 10 | 11 | input.when_activated = led.on 12 | input.when_deactivated =led.off 13 | 14 | pause() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/inputs/potentiometer_led.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-analog-inputs-python-mcp3008/ 2 | 3 | from gpiozero import PWMLED, MCP3008 4 | from time import sleep 5 | 6 | #create an object called pot that refers to MCP3008 channel 0 7 | pot = MCP3008(0) 8 | 9 | #create a PWMLED object called led that refers to GPIO 14 10 | led = PWMLED(14) 11 | 12 | while True: 13 | if(pot.value < 0.001): 14 | led.value = 0 15 | else: 16 | led.value = pot.value 17 | print(pot.value) 18 | sleep(0.1) -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/inputs/pushbutton_is_pressed.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-digital-inputs-python/ 2 | 3 | from gpiozero import Button, LED 4 | 5 | led = LED(14) 6 | button = Button(4) 7 | 8 | while True: 9 | if button.is_pressed: 10 | led.on() 11 | else: 12 | led.off() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/inputs/pushbutton_led.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-digital-inputs-python/ 2 | 3 | from gpiozero import Button, LED 4 | from signal import pause 5 | 6 | led = LED(14) 7 | button = Button(4) 8 | 9 | button.when_pressed = led.on 10 | button.when_released = led.off 11 | 12 | pause() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/inputs/toggle_when_pressed.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-digital-inputs-python/ 2 | 3 | from gpiozero import Button, LED 4 | from signal import pause 5 | 6 | led = LED(14) 7 | button = Button (4) 8 | 9 | button.when_pressed = led.toggle 10 | 11 | pause() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/led_blink.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/projects-raspberry-pi/ 2 | 3 | from gpiozero import LED 4 | from signal import pause 5 | 6 | led = LED(14) 7 | 8 | # blinking an LED forever 9 | led.blink() 10 | pause() 11 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/led_toggle.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/projects-raspberry-pi/ 2 | 3 | from gpiozero import LED 4 | from time import sleep 5 | 6 | led = LED(14) 7 | 8 | # blinking an LED forever 9 | while True: 10 | led.toggle() 11 | sleep(1) 12 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/new_dht_basic.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-dht11-dht22-python/ 2 | # Based on Adafruit_CircuitPython_DHT Library Example 3 | 4 | import time 5 | import board 6 | import adafruit_dht 7 | 8 | # Sensor data pin is connected to GPIO 4 9 | sensor = adafruit_dht.DHT22(board.D4) 10 | # Uncomment for DHT11 11 | #sensor = adafruit_dht.DHT11(board.D4) 12 | 13 | while True: 14 | try: 15 | # Print the values to the serial port 16 | temperature_c = sensor.temperature 17 | temperature_f = temperature_c * (9 / 5) + 32 18 | humidity = sensor.humidity 19 | print("Temp={0:0.1f}ºC, Temp={1:0.1f}ºF, Humidity={2:0.1f}%".format(temperature_c, temperature_f, humidity)) 20 | 21 | except RuntimeError as error: 22 | # Errors happen fairly often, DHT's are hard to read, just keep going 23 | print(error.args[0]) 24 | time.sleep(2.0) 25 | continue 26 | except Exception as error: 27 | sensor.exit() 28 | raise error 29 | 30 | time.sleep(3.0) 31 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/pir_motion_sensor.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-detect-motion-pir-python/ 2 | 3 | from gpiozero import MotionSensor 4 | from signal import pause 5 | 6 | pir = MotionSensor(18) 7 | 8 | def motion_function(): 9 | print("Motion Detected") 10 | 11 | def no_motion_function(): 12 | print("Motion stopped") 13 | 14 | pir.when_motion = motion_function 15 | pir.when_no_motion = no_motion_function 16 | 17 | pause() 18 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/pwm/fade_led.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-pwm-python/ 2 | 3 | from gpiozero import PWMLED 4 | from time import sleep 5 | 6 | led = PWMLED(14) 7 | 8 | led.value = 1 #LED fully on 9 | sleep(1) 10 | led.value = 0.5 #LED half-brightness 11 | sleep(1) 12 | led.value = 0 #LED fully off 13 | sleep(1) 14 | 15 | try: 16 | # fade in and out forever 17 | while True: 18 | #fade in 19 | for duty_cycle in range(0, 100, 1): 20 | led.value = duty_cycle/100.0 21 | sleep(0.05) 22 | 23 | #fade out 24 | for duty_cycle in range(100, 0, -1): 25 | led.value = duty_cycle/100.0 26 | sleep(0.05) 27 | 28 | except KeyboardInterrupt: 29 | print("Stop the program and turning off the LED") 30 | led.value = 0 31 | pass -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/pwm/fade_led_pulse.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-pwm-python/ 2 | 3 | from gpiozero import PWMLED 4 | from signal import pause 5 | 6 | led = PWMLED(14) 7 | 8 | # pulse an LED forever 9 | led.pulse() 10 | pause() -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/pwm/fade_pwm_output_device.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-pwm-python/ 2 | 3 | from gpiozero import PWMOutputDevice 4 | from time import sleep 5 | 6 | led = PWMOutputDevice(14) 7 | 8 | led.value = 1 #LED fully on 9 | sleep(1) 10 | led.value = 0.5 #LED half-brightness 11 | sleep(1) 12 | led.value = 0 #LED fully off 13 | sleep(1) 14 | 15 | try: 16 | # Fade in and out forever 17 | while True: 18 | #fade in 19 | for duty_cycle in range(0, 100, 1): 20 | led.value = duty_cycle/100.0 21 | sleep(0.05) 22 | 23 | #fade out 24 | for duty_cycle in range(100, 0, -1): 25 | led.value = duty_cycle/100.0 26 | sleep(0.05) 27 | 28 | except KeyboardInterrupt: 29 | print("Stop the program and turning off the LED") 30 | led.value = 0 31 | pass -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/pwm/pulse_with_blink.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-pwm-python/ 2 | 3 | from gpiozero import PWMLED 4 | from signal import pause 5 | 6 | led = PWMLED(14) 7 | 8 | #blink(on_time=1, off_time=1, fade_in_time=0, fade_out_time=0, n=None, background=True) 9 | # fading an LED forever 10 | led.blink(0, 0, 1, 1, None, True) 11 | pause() 12 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/send_email.py: -------------------------------------------------------------------------------- 1 | # Complete Project Details: https://RandomNerdTutorials.com/raspberry-pi-send-email-python-smtp-server/ 2 | 3 | import smtplib 4 | from email.message import EmailMessage 5 | 6 | #Set the sender email and password and recipient emaiç 7 | from_email_addr ="REPLACE_WITH_THE_SENDER_EMAIL" 8 | from_email_pass ="REPLACE_WITH_THE_SENDER_EMAIL_APP_PASSWORD" 9 | to_email_addr ="REPLACE_WITH_THE_RECIPIENT_EMAIL" 10 | 11 | # Create a message object 12 | msg = EmailMessage() 13 | 14 | # Set the email body 15 | body ="Hello from Raspberry Pi" 16 | msg.set_content(body) 17 | 18 | # Set sender and recipient 19 | msg['From'] = from_email_addr 20 | msg['To'] = to_email_addr 21 | 22 | # Set your email subject 23 | msg['Subject'] = 'TEST EMAIL' 24 | 25 | # Connecting to server and sending email 26 | # Edit the following line with your provider's SMTP server details 27 | server = smtplib.SMTP('smtp.gmail.com', 587) 28 | 29 | # Comment out the next line if your email provider doesn't use TLS 30 | server.starttls() 31 | # Login to the SMTP server 32 | server.login(from_email_addr, from_email_pass) 33 | 34 | # Send the message 35 | server.send_message(msg) 36 | 37 | print('Email sent') 38 | 39 | #Disconnect from the Server 40 | server.quit() 41 | -------------------------------------------------------------------------------- /Projects/Raspberry-Pi/take_photo.py: -------------------------------------------------------------------------------- 1 | # Rui Santos & Sara Santos - Random Nerd Tutorials 2 | # Complete project details at https://RandomNerdTutorials.com/raspberry-pi-picamera2-python/ 3 | 4 | from picamera2 import Picamera2, Preview 5 | import time 6 | 7 | picam2 = Picamera2() 8 | 9 | camera_config = picam2.create_preview_configuration() 10 | picam2.configure(camera_config) 11 | 12 | picam2.start_preview(Preview.QTGL) 13 | picam2.start() 14 | 15 | time.sleep(2) 16 | 17 | picam2.capture_file("test_photo.jpg") -------------------------------------------------------------------------------- /Projects/ReceiveDemo_Advanced.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at http://randomnerdtutorials.com 4 | *********/ 5 | 6 | #include 7 | 8 | RCSwitch mySwitch = RCSwitch(); 9 | 10 | void setup() { 11 | Serial.begin(9600); 12 | mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 13 | } 14 | 15 | void loop() { 16 | if (mySwitch.available()) { 17 | output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); 18 | mySwitch.resetAvailable(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/SerialDebug/Example.ino: -------------------------------------------------------------------------------- 1 | // Example from ladyada.net/learn/arduino/lesson4.html 2 | 3 | int a = 5; 4 | int b = 10; 5 | int c = 20; 6 | 7 | void setup() // run once, when the sketch starts 8 | { 9 | Serial.begin(9600); // set up Serial library at 9600 bps 10 | 11 | Serial.println("Here is some math: "); 12 | 13 | Serial.print("a = "); 14 | Serial.println(a); 15 | Serial.print("b = "); 16 | Serial.println(b); 17 | Serial.print("c = "); 18 | Serial.println(c); 19 | 20 | Serial.print("a + b = "); // add 21 | Serial.println(a + b); 22 | 23 | Serial.print("a * c = "); // multiply 24 | Serial.println(a * c); 25 | 26 | Serial.print("c / b = "); // divide 27 | Serial.println(c / b); 28 | 29 | Serial.print("b - c = "); // subtract 30 | Serial.println(b - c); 31 | } 32 | 33 | void loop() // we need this to be here even though its empty 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /Projects/Ultrasonic_Sensor_HC-SR04_with_NewPing.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Posted on https://randomnerdtutorials.com 3 | * created by http://playground.arduino.cc/Code/NewPing 4 | */ 5 | 6 | #include 7 | 8 | #define TRIGGER_PIN 11 9 | #define ECHO_PIN 12 10 | #define MAX_DISTANCE 200 11 | 12 | // NewPing setup of pins and maximum distance 13 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); 14 | 15 | void setup() { 16 | Serial.begin(9600); 17 | } 18 | 19 | void loop() { 20 | delay(50); 21 | unsigned int distance = sonar.ping_cm(); 22 | Serial.print(distance); 23 | Serial.println("cm"); 24 | } 25 | -------------------------------------------------------------------------------- /Projects/Yves-Arbour/counterMax.lua: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /Projects/Yves-Arbour/init_server.lua: -------------------------------------------------------------------------------- 1 | -- Rui Santos - ESP8266 Server 2 | -- Modified by Yves Arbour to ennable print string to go directly to an Excel sheet with Things Gateway 3 | 4 | print("ESP8266 Server") 5 | wifi.setmode(wifi.STATIONAP); 6 | wifi.ap.config({ssid="test",pwd="12345678"}); 7 | print("Server IP Address:",wifi.ap.getip()) 8 | 9 | sv = net.createServer(net.TCP) 10 | sv:listen(80, function(conn) 11 | conn:on("receive", function(conn, receivedData) 12 | --print("Received Data"..receivedData) 13 | print(receivedData)-- string "Received Data" removed... 14 | --Things Gateway ignores strings that do not start with proper command... 15 | --XLS in this case for Excel sheet 16 | end) 17 | conn:on("sent", function(conn) 18 | collectgarbage() 19 | end) 20 | end) 21 | -------------------------------------------------------------------------------- /Projects/blink_led_esp8266.ino: -------------------------------------------------------------------------------- 1 | /********* 2 | Rui Santos 3 | Complete project details at http://randomnerdtutorials.com 4 | *********/ 5 | 6 | int pin = 2; 7 | 8 | void setup() { 9 | // initialize GPIO 2 as an output. 10 | pinMode(pin, OUTPUT); 11 | } 12 | 13 | // the loop function runs over and over again forever 14 | void loop() { 15 | digitalWrite(pin, HIGH); // turn the LED on (HIGH is the voltage level) 16 | delay(1000); // wait for a second 17 | digitalWrite(pin, LOW); // turn the LED off by making the voltage LOW 18 | delay(1000); // wait for a second 19 | } 20 | -------------------------------------------------------------------------------- /Projects/decode-rf-arduino/ReceiveDemo_Advanced.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | If you want to visualize a telegram copy the raw data and 7 | paste it into http://test.sui.li/oszi/ 8 | */ 9 | 10 | #include 11 | 12 | RCSwitch mySwitch = RCSwitch(); 13 | 14 | void setup() { 15 | Serial.begin(9600); 16 | mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 17 | } 18 | 19 | void loop() { 20 | if (mySwitch.available()) { 21 | output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); 22 | mySwitch.resetAvailable(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Projects/decode-rf-arduino/SendDemoExample.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Based on the SendDemo example from the RC Switch library 3 | https://github.com/sui77/rc-switch/ 4 | */ 5 | 6 | #include 7 | RCSwitch mySwitch = RCSwitch(); 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | 12 | // Transmitter is connected to Arduino Pin #10 13 | mySwitch.enableTransmit(10); 14 | 15 | // Optional set pulse length. 16 | mySwitch.setPulseLength(REPLACE_WITH_YOUR_PULSE_LENGTH); 17 | 18 | // Optional set protocol (default is 1, will work for most outlets) 19 | mySwitch.setProtocol(REPLACE_WITH_YOUR_PROTOCOL); 20 | 21 | // Optional set number of transmission repetitions. 22 | // mySwitch.setRepeatTransmit(15); 23 | } 24 | 25 | void loop() { 26 | // Binary code - button 3 27 | mySwitch.send("000101010101000101010101"); 28 | delay(1000); 29 | mySwitch.send("000101010101000101010100"); 30 | delay(1000); 31 | 32 | // Binary code - button 4 33 | mySwitch.send("000101010101010001010101"); 34 | delay(1000); 35 | mySwitch.send("000101010101010001010100"); 36 | delay(1000); 37 | } 38 | -------------------------------------------------------------------------------- /Projects/dht_temperature_serial_plotter.ino: -------------------------------------------------------------------------------- 1 | // Example testing sketch for various DHT humidity/temperature sensors 2 | // Written by ladyada modified by Rui Santos 3 | 4 | #include "DHT.h" 5 | 6 | #define DHTPIN 2 // what pin we're connected to 7 | 8 | // Uncomment whatever type you're using! 9 | #define DHTTYPE DHT11 // DHT 11 10 | //#define DHTTYPE DHT22 // DHT 22 (AM2302) 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | // Initialize DHT sensor for normal 16mhz Arduino 14 | DHT dht(DHTPIN, DHTTYPE); 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | Serial.println("DHTxx test!"); 19 | dht.begin(); 20 | } 21 | 22 | void loop() { 23 | // Read temperature as Celsius 24 | float t = dht.readTemperature(); 25 | 26 | // Check if any reads failed and exit early (to try again). 27 | if (isnan(t)) { 28 | return; 29 | } 30 | 31 | // Prints temperature in the Arduino Plotter Tool 32 | Serial.println(t); 33 | 34 | // Wait a few seconds between measurements. 35 | delay(10); 36 | } 37 | -------------------------------------------------------------------------------- /Projects/esp_print_adc.lua: -------------------------------------------------------------------------------- 1 | print(adc.read(0)) 2 | -------------------------------------------------------------------------------- /Projects/rain_sensor_arduino.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | All the resources for this project: 4 | http://randomnerdtutorials.com/ 5 | 6 | */ 7 | 8 | int rainPin = A0; 9 | int greenLED = 6; 10 | int redLED = 7; 11 | // you can adjust the threshold value 12 | int thresholdValue = 500; 13 | 14 | void setup(){ 15 | pinMode(rainPin, INPUT); 16 | pinMode(greenLED, OUTPUT); 17 | pinMode(redLED, OUTPUT); 18 | digitalWrite(greenLED, LOW); 19 | digitalWrite(redLED, LOW); 20 | Serial.begin(9600); 21 | } 22 | 23 | void loop() { 24 | // read the input on analog pin 0: 25 | int sensorValue = analogRead(rainPin); 26 | Serial.print(sensorValue); 27 | if(sensorValue < thresholdValue){ 28 | Serial.println(" - It's wet"); 29 | digitalWrite(greenLED, LOW); 30 | digitalWrite(redLED, HIGH); 31 | } 32 | else { 33 | Serial.println(" - It's dry"); 34 | digitalWrite(greenLED, HIGH); 35 | digitalWrite(redLED, LOW); 36 | } 37 | delay(500); 38 | } 39 | -------------------------------------------------------------------------------- /Projects/smoke_detector.ino: -------------------------------------------------------------------------------- 1 | /******* 2 | 3 | All the resources for this project: 4 | http://randomnerdtutorials.com/ 5 | 6 | *******/ 7 | 8 | int redLed = 12; 9 | int greenLed = 11; 10 | int buzzer = 10; 11 | int smokeA0 = A5; 12 | // Your threshold value 13 | int sensorThres = 400; 14 | 15 | void setup() { 16 | pinMode(redLed, OUTPUT); 17 | pinMode(greenLed, OUTPUT); 18 | pinMode(buzzer, OUTPUT); 19 | pinMode(smokeA0, INPUT); 20 | Serial.begin(9600); 21 | } 22 | 23 | void loop() { 24 | int analogSensor = analogRead(smokeA0); 25 | 26 | Serial.print("Pin A0: "); 27 | Serial.println(analogSensor); 28 | // Checks if it has reached the threshold value 29 | if (analogSensor > sensorThres) 30 | { 31 | digitalWrite(redLed, HIGH); 32 | digitalWrite(greenLed, LOW); 33 | tone(buzzer, 1000, 200); 34 | } 35 | else 36 | { 37 | digitalWrite(redLed, LOW); 38 | digitalWrite(greenLed, HIGH); 39 | noTone(buzzer); 40 | } 41 | delay(100); 42 | } 43 | -------------------------------------------------------------------------------- /Projects/soil_moisture_sensor_arduino.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | All the resources for this project: 4 | http://randomnerdtutorials.com/ 5 | 6 | */ 7 | 8 | int rainPin = A0; 9 | int greenLED = 6; 10 | int redLED = 7; 11 | // you can adjust the threshold value 12 | int thresholdValue = 800; 13 | 14 | void setup(){ 15 | pinMode(rainPin, INPUT); 16 | pinMode(greenLED, OUTPUT); 17 | pinMode(redLED, OUTPUT); 18 | digitalWrite(greenLED, LOW); 19 | digitalWrite(redLED, LOW); 20 | Serial.begin(9600); 21 | } 22 | 23 | void loop() { 24 | // read the input on analog pin 0: 25 | int sensorValue = analogRead(rainPin); 26 | Serial.print(sensorValue); 27 | if(sensorValue < thresholdValue){ 28 | Serial.println(" - Doesn't need watering"); 29 | digitalWrite(redLED, LOW); 30 | digitalWrite(greenLED, HIGH); 31 | } 32 | else { 33 | Serial.println(" - Time to water your plant"); 34 | digitalWrite(redLED, HIGH); 35 | digitalWrite(greenLED, LOW); 36 | } 37 | delay(500); 38 | } 39 | -------------------------------------------------------------------------------- /Projects/tft/draw_shapes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | // include TFT and SPI libraries 7 | #include 8 | #include 9 | 10 | // pin definition for Arduino UNO 11 | #define cs 10 12 | #define dc 9 13 | #define rst 8 14 | 15 | 16 | // create an instance of the library 17 | TFT TFTscreen = TFT(cs, dc, rst); 18 | 19 | void setup() { 20 | 21 | //initialize the library 22 | TFTscreen.begin(); 23 | 24 | // clear the screen with a black background 25 | TFTscreen.background(0, 0, 0); 26 | } 27 | 28 | void loop() { 29 | 30 | //generate a random color 31 | int redRandom = random(0, 255); 32 | int greenRandom = random (0, 255); 33 | int blueRandom = random (0, 255); 34 | 35 | // set the color for the figures 36 | TFTscreen.stroke(redRandom, greenRandom, blueRandom); 37 | 38 | // light up a single point 39 | TFTscreen.point(80,64); 40 | // wait 200 miliseconds until change to next figure 41 | delay(500); 42 | 43 | // draw a line 44 | TFTscreen.line(0,64,160,64); 45 | delay(500); 46 | 47 | //draw a square 48 | TFTscreen.rect(50,34,60,60); 49 | delay(500); 50 | 51 | //draw a circle 52 | TFTscreen.circle(80,64,30); 53 | delay(500); 54 | 55 | //erase all figures 56 | TFTscreen.background(0,0,0); 57 | } 58 | -------------------------------------------------------------------------------- /Projects/tft/write_text.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Rui Santos 3 | * Complete Project Details http://randomnerdtutorials.com 4 | */ 5 | 6 | // include TFT and SPI libraries 7 | #include 8 | #include 9 | 10 | // pin definition for Arduino UNO 11 | #define cs 10 12 | #define dc 9 13 | #define rst 8 14 | 15 | 16 | // create an instance of the library 17 | TFT TFTscreen = TFT(cs, dc, rst); 18 | 19 | void setup() { 20 | 21 | //initialize the library 22 | TFTscreen.begin(); 23 | 24 | // clear the screen with a black background 25 | TFTscreen.background(0, 0, 0); 26 | //set the text size 27 | TFTscreen.setTextSize(2); 28 | } 29 | 30 | void loop() { 31 | 32 | //generate a random color 33 | int redRandom = random(0, 255); 34 | int greenRandom = random (0, 255); 35 | int blueRandom = random (0, 255); 36 | 37 | // set a random font color 38 | TFTscreen.stroke(redRandom, greenRandom, blueRandom); 39 | 40 | // print Hello, World! in the middle of the screen 41 | TFTscreen.text("Hello, World!", 6, 57); 42 | 43 | // wait 200 miliseconds until change to next color 44 | delay(200); 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Random Nerd Tutorials - *Created by Rui Santos & Sara Santos* 2 | 3 | Random Nerd Tutorials is a blog where we share electronics projects, tutorials and reviews. 4 | 5 | We help makers, hobbyists and engineers build electronics projects. We make projects about: ESP32, ESP32-CAM, ESP8266, Raspberry Pi, Raspberry Pi Pico, Arduino, Home Automation and Internet of Things. 6 | 7 | For complete project details, go to » https://RandomNerdTutorials.com/ 8 | 9 | Grab our eBooks and courses » https://RandomNerdTutorials.com/courses/ 10 | 11 | Read our product reviews » https://MakerAdvisor.com/ 12 | 13 | ## Browse all our projects by category: 14 | - ESP32 Projects (Arduino IDE): https://RandomNerdTutorials.com/projects-esp32/ 15 | - ESP8266 Projects (Arduino IDE): https://RandomNerdTutorials.com/projects-esp8266/ 16 | - ESP32/ESP8266 Projects (MicroPython): https://RandomNerdTutorials.com/projects-esp32-esp8266-micropython/ 17 | - ESP32-CAM Projects: https://RandomNerdTutorials.com/projects-esp32-cam/ 18 | - Raspberry Pi Projects: https://RandomNerdTutorials.com/projects-raspberry-pi/ 19 | - Raspberry Pi Pico Projects: https://RandomNerdTutorials.com/projects-raspberry-pi-pico/ 20 | - Arduino board Projects: https://RandomNerdTutorials.com/projects-arduino/ 21 | --------------------------------------------------------------------------------