search

Latest posts


SSH into Ubuntu

Allow MySQL service listen on the server IP address instead of 127.0.0.1

vi /etc/mysql/mysql.conf.d/mysqld.cnf

Under [msqld], change bind-address = 127.0.0.1 to the db_server_IP_address.

Restart the MySQL server:

sudo systemctl restart mysql

Allow SQL traffic through the firewall:

sudo ufw allow mysql

Create a new user with permissions:

CREATE USER 'remote_username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dbname.* TO 'remote_username'@'%' IDENTIFIED BY 'password';

Update an existing database and user to allow remote access:

mysql> update db set Host='202.54.10.20' where Db='webdb';
mysql> update user set Host='202.54.10.20' where user='webadmin';

202.54.10.20 is the remote client IP address

Next we’ll connect the Feather to Wi-Fi and report the temperature and humidity data to a cloud MySQL database server through a web page.

Using the MAC address for the Feather you found in step 2, register the Feather on Devicenet.

Paste the is sketch and make necessary edits (indicated with //TODO):


// https://github.com/openhomeautomation/esp8266-cloud/blob/master/cloud_data_logger/cloud_data_logger.ino // Import required libraries #include "ESP8266WiFi.h" #include "DHT.h" // WiFi parameters const char* ssid = "put your SSID between these quotes"; // TODO const char* password = "put your wi-fi password between these quotes"; // TODO // Data Pin #define DHTPIN 2 // Ensure the data wire (yellow) for the DHT22 is on pin 2 // Use DHT22 sensor #define DHTTYPE DHT22 //for AM2302 // Initialize DHT sensor DHT dht(DHTPIN, DHTTYPE); // Host const char* host = "put the web host between these quotes"; // TODO void setup() { // Start Serial Serial.begin(115200); delay(10); // Init DHT dht.begin(); // We start by connecting to a WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void loop() { Serial.print("Connecting to "); Serial.println(host); // Use WiFiClient class to create TCP connections WiFiClient client; const int httpPort = 80; if (!client.connect(host, httpPort)) { Serial.println("connection failed"); return; } // Reading temperature and humidity float h = dht.readHumidity(); // Read temperature as Celsius float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // This will send the request to the server // TODO // /iot?sensor=0 <-- this should be changed to reflect the page and sensor ID // it is passing sensor, temp, and humidity as URL GET parameters // the iot page is parsing these parameters into variables and writing them to the database client.print(String("GET /iot?sensor=0&temp=") + String(f) + "&humidity=" + String(h) + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); delay(10); Serial.print("data written to db"); Serial.println(); Serial.println("closing connection"); // Repeat every 15 minutes delay(900000); // TODO - change this to reflect how frequently you want the data written to the database }

At this point, you should visit the website, click on your sensor ID and see data on the web site. It sends the first data as soon as it’s powered on and (in this case) every ~15 minutes.

You can open the serial monitor (magnifying glass), set the baud to 115200, and see the serial print output. Press the reset button on your Feather. Each time it is reset it will write to the serial monitor and the database.

 


For this, I purchased:

solderless breadboard (3 pack) – $9.99 eachhttps://www.amazon.com/gp/product/B01EV6LJ7G

Adafruit AM2302 temperature & humidity sensor – $15 eachhttps://www.adafruit.com/product/393

 

Connect the AM2302 sensor to the Feather using the breadboard:

Download the DHT-sensor-library from Adafruit’s Github

Unzip and place the folder in

On a PC:   /Program Files (x86)/Arduino/libraries/DHT-sensor-master-library

On a Mac:   /Documents/Arduino/libraries/DHT-sensor-master-library

Sketch –> Include Library –> Manage Libraries

Search for “Adafruit Unified” and install “Adafruit Unified Sensor“.

File –> Open –> browse to

On a PC:   /Program Files (x86)/Arduino/libraries/DHT-sensor-master-library/examples/DHTtester/DHTtester.ino

On a Mac:   /Documents/Arduino/libraries/DHT-sensor-master-library/examples/DHTtester/DHTtester.ino

Be sure to set the correct data pin (second line of code) and upload to the Feather.

After it uploads, click Tools –> Serial Monitor

You should now see temperature and humidity data refreshing on your screen every 2 seconds. Since the data pin is pin #2, the same as the blue LED, it blinks with each read.

 

DHTester.ino


// Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain #include "DHT.h" #define DHTPIN 2 // what digital pin we're connected to // Uncomment whatever type you're using! //#define DHTTYPE DHT11 // DHT 11 #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin(); } void loop() { // Wait a few seconds between measurements. delay(2000); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hic); Serial.print(" *C "); Serial.print(hif); Serial.println(" *F"); }

 


Create a new sketch with the following code and upload it:

#include "ESP8266WiFi.h"

void setup(){

Serial.begin(115200);
delay(500);

Serial.println();
Serial.print("MAC: ");
Serial.println(WiFi.macAddress());

}

void loop(){}

Open the serial monitor (magnifying glass).

Press the reset button on your Feather. You should then see the MAC address associate with the wireless Ethernet radio on your Feather appear in the serial monitor.

If not, adjust your baud rate to 115,000.

 

After you have the MAC address you need to register it on to DeviceNet.

 


For this project I purchased an Arduino Feather Huzzah

Adafruit 2821 Feather HUZZAH with ESP8266 Wi-Fihttps://www.adafruit.com/product/2821


Mac installation:

Following the instructions on the Feather Huzzah page, I downloaded the latest Arduino IDE:Arduino IDE.Next, I downloaded and installed the Legacy CP2104 USB driver for my Mac from here.

 

Windows installation:

I downloaded the Windows installer (.exe) file from here. Be sure to download the installer version, not from an app store. The appropriate drivers are bundled with the installer version.


Using a micro-USB to regular USB cable I connected the Feather to my Mac. On connection, the on-board LEDs blinked indicating connection and power.

After the Arduino IDE loads, I added the ESP8266 board manager by navigating to Arduino –> Preferences and adding http://arduino.esp8266.com/stable/package_esp8266com_index.json in the “Additional Boards Manager URLs” field and click “OK“.

Tools –> Board –> Board Manager and search for “esp8266

Select “esp8266 by ESP8266 Community” and click “Install” –> “OK

 

Tools –> Board –> select “Adafruit Feather HUZZAH ESP8266“. If you need additional settings, refer to these instructions

 

In the Arduino IDE, create a new sketch. Replace the default code with the following:


const int blink = 0; // red LED should blink - set this to 2 to blink the blue LED // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(blink, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(blink, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for one second (1000 milliseconds) digitalWrite(blink, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for one second (1000 milliseconds) }

Save the sketch as blink.ino.

Connect your Feather HUZZAH to your computer via USB and set the correct port.

Tools –> Port

For Mac:

For Windows:

 

From the sketch window in the IDE, click “Upload

The file should upload and the red LED will blink. You can modify the constant to be “2”, save and re-upload. The blue LED should now be blinking.

 

 


How do I remove all data from a table and reset the AUTO_INCREMENT value back to 1?


TRUNCATE database_name.table_name

 


How do I change the AUTO_INCREMENT value?


ALTER TABLE database_name.table_name AUTO_INCREMENT=5000

Configure TextEdit on your Mac for use in coding projects, edit the settings below.

TextEdit –> Preferences –>

TextEdit –> Preferences –> New Document

 

TextEdit –> Preferences –> Open and Save


To unlock a user account on Oracle SQL:


ALTER USER username ACCOUNT UNLOCK;

 

To reset the password on an Oracle SQL account:


ALTER USER username IDENTIFIED BY a_new_password;

 


Visit https://futureboy.us/stegano/

Steganography encoding

Steganography encoding

 Original iPhone 5s photo

 iPhone 5s image w/ hidden message. The password is ‘pAssw0rd’.

The images were FTP’d into a directory and this WordPress post linked to the images. If the images were uploaded into the WordPress media manager, the steganography was lost – maybe due to compression(?).


‹ previous posts
close
search

Hi, guest!

settings

menu