Group Details Private

administrators

Member List

  • NodeMCU MQ135 air quality sensor tutorial

    Preparation

    Before we begin, you will have to obtain:

    Import Library

    Arduino > Sketch > Include Library > Add .ZIP library (Select the MQ135 Library zip file that you have downloaded from above)
    

    Connect the NodeMCU to MQ135 sensor

    Connect NodeMCU A0 to MQ135 AO
    Connect NodeMCU GND to MQ135 GND
    Connect NodeMCU 3.3V to MQ135 VCC
    

    Burnout

    It is necessary to "burnout" the sensor for first use to calibrate proper rzero value, to do so paste following code to your arduino window :

    #include "MQ135.h"
    const int ANALOGPIN=0;
    MQ135 gasSensor = MQ135(ANALOGPIN);
    void setup(){
      Serial.begin(115200);      // sets the serial port to 115200
    }
    void loop(){
      float rzero = gasSensor.getRZero();
      Serial.println(rzero);
      delay(1000);
    }
    
    • Upload the code to NodeMCU
    • Open the serial monitor : Tools > Serial Monitor

    Let it running for an hour or two until you get constant rzero value. Write down that RZERO value as you will need it for later use.

    If you made it up to here, you almost got to the end.

    ThingSpeak

    This is the platform that we are going to use to store our measures and display them in a nice graph that we can embed to any website or similar. (This tutorial might expand in future to a selfhosted variant of storing and displaying data)

    Measure Air Quality

    Adapt following code to reflect your RZERO value, API key, SSID and password.

    Note: RZERO is the value from the burnout section.

    #include <ESP8266WiFi.h>
    #include "MQ135.h"
    #define RZERO 76.63
    const int ANALOGPIN=0;
    MQ135 gasSensor = MQ135(ANALOGPIN);
    
    
    String apiKey = "WRITE-API-KEY"; // Enter your Write API key from ThingSpeak
    const char *ssid = "SSIDNAME"; // replace with your wifi ssid 
    const char *pass = "PASSWORDHERE"; // replace this field with your password
    const char* server = "api.thingspeak.com";
    WiFiClient client;
    void setup()
    {
    Serial.begin(115200);
    delay(10);
    Serial.println("Connecting to ");
    Serial.println(ssid);
    WiFi.begin(ssid, pass);
    while (WiFi.status() != WL_CONNECTED)
    {
    delay(500);
    Serial.print(".");
    }
    Serial.println("");
    Serial.println("WiFi connected");
    }
    void loop()
    {
      float ppm = gasSensor.getPPM();
      Serial.println(ppm);
      delay(1000);
    
    if (client.connect(server, 80)) 
    {
    String postStr = apiKey;
    postStr += "&field1=";
    postStr += String(ppm);
    postStr += "r\n";
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(postStr.length());
    client.print("\n\n");
    client.print(postStr);
    Serial.print("Gas Level: ");
    Serial.println(ppm);
    Serial.println("Data Send to Thingspeak");
    }
    client.stop();
    Serial.println("Waiting...");
    
    // thingspeak needs minimum 15 sec delay between updates.
    delay(1500);
    }
    

    That is it, from here you are sending values to ThingSpeak platform, you got yourself a nice graph, and you are monitoring air quality 🙂

    Here is the image of values to know when the air is bad :

    air quality

    posted in Tutorials
  • RE: Remote Live Backing up Custom Game Server With SQlite3 databases?

    @FriendlyGamer You can always adapt the script by changing .db to .sqlite, i will do it ASAP.

    Regarding the shared hosting/storage server, i am clueless what mechanism they are using as i do not know which panel they are using, have you checked their documentation ? You could raise a ticket with question to obtain necessary info... I just assume it is within options somewhere, some hostings generate public/private key pair for you to import to the server. Can you at least tell me which provider is that ? Maybe a link to their website?

    You can read your public key from the server with command cat ~/.ssh/id_rsa.pub

    By the way i have changed the script to reflect .sqlite extension. Since it is just a file, your db could be ending with .anything, so you can compare last commit and adapt it for future use 😉

    posted in #! Request Script #!
  • RE: Remote Live Backing up Custom Game Server With SQlite3 databases?

    @FriendlyGamer

    I have updated the script to get all names of DBs in the directory path and backup them to specified directory.

    Check the script location : https://git.shell5.dev/shell5dev/installation-scripts/tree/master/FriendlyGamer-gameserver-db-backup

    Regarding the remote storage, i suppose that you have to add your public key manually to the control panel and obtain parameters like server URL which you should input to the script in format [email protected]

    posted in #! Request Script #!
  • RE: Remote Live Backing up Custom Game Server With SQlite3 databases?

    @FriendlyGamer

    1. Sorry i haven't saw it was about multiple databases, was probably too tired 🙂 . How many databases are there ? Are they all in same directory?

    2. I haven't mentioned that to be able to use rsync, most elegant way would be to copy your public key to remote server by issuing from game server ssh-copy-id [email protected]. In case you haven't generated public/private key, you can do so by issuing ssh-keygen -T RSA. I will update the readme on gitlab.

    Also it might be a good idea to determine "remote storage", is it another linux server? If not, what is it and what protocols does it support ?

    posted in #! Request Script #!
  • RE: Remote Live Backing up Custom Game Server With SQlite3 databases?

    @FriendlyGamer

    Please make backups manually before testing/runing the script. I have tested the script on "fake" files that i have generated but make the backups manually to be 100% safe if anything goes wrong so that you can restore the server.

    Gitlab script directory: https://git.shell5.dev/shell5dev/installation-scripts/tree/master/FriendlyGamer-gameserver-db-backup
    Gitlab master repo: https://git.shell5.dev/shell5dev/installation-scripts
    Github mirror: https://github.com/shell5dev/Installation-Scripts

    If everything works ok, you can make a cronjob to run this script automatically for example weekly, every sunday at 1AM.

    Edit crontab
    
    #crontab -e 
    
    Insert the cron job:
    
    # 0 1 * * 0 /path/to/script/backup.sh
    
    

    Note, do not forget to add execution rights to the script chmod +x backup.sh and to change variables within script.

    posted in #! Request Script #!
  • RE: Remote Live Backing up Custom Game Server With SQlite3 databases?

    @FriendlyGamer

    I will get to it, in a day or two due to busy working week 🙂

    posted in #! Request Script #!
  • RE: Remote Live Backing up Custom Game Server With SQlite3 databases?

    @FriendlyGamer

    Hey there.

    From Sqlite's docs :

    If you want to do a backup while users are connected, you can use sqlite3 to create the backup.
    
    You can dump the database to a text file of sql commands like this: sqlite3 db.sqlite .dump > kanboard.dump.sql
    Another option is to create a backup in sqlite format: sqlite3 db.sqlite ".backup db.backup.sqlite"
    

    So yes, you can make a backup while the DB is in the use.

    There are several approaches to this request.. Do you want to initiate backups & transfer from your server, or do you want to initiate them from your backup location/server ?

    About the notification, which one do you want ? Email, Slack, Discord, etc...

    posted in #! Request Script #!
  • Raspberry Pi CPU Bitcoin Altcoin Miner

    RaspberryPi-CPUMiner + CPUMiner with new algorithms (check bellow)

    CPUMiner for RaspberryPi Zero, Pi 3, Pi 2, B+, A+.

    Clone of: pooler

    Instructions for PiZero:

    Download minerd to your PiZero, make it executable & run:

    **# wget https://github.com/demogorgonz/RaspberryPi-CPUMiner/raw/master/minerd**
    
    **# chmod +x minerd**
    
    **# ./minerd -h**
    

    Or

    Download minerd.tar.bz2 archive, extract & run:
    
    **# wget https://github.com/demogorgonz/RaspberryPi-CPUMiner/releases/download/v.1.0/minerd.tar.bz2**
    
    **# tar xjf minerd.tar.bz2**
    
    **# ./minerd -h**
    

    Build it yourself for Pi 3, Pi 2, B+, A+ :

    There is auto build script which will install dependencies to your Raspberry and build "minerd" - see "cpuminer-source" folder and locate build.sh file.

    git clone https://github.com/demogorgonz/RaspberryPi-CPUMiner.git
    
    cd cpuminer-source/
    
    sudo bash build.sh
    

    CPUMiner with new algorithms (EXPERIMENTAL)

    clone of lucasjones

    Download page: Releases v1.1

    Build it yourself for Pi 3, Pi 2, B+, A+ :

    cd cpuminer-newalgorithms
    
    sudo bash build.sh
    

    Code Source

    posted in Tutorials
  • Hardware upgrade 18.4.2019

    We have migrated last night everything to new hardware. More about the hardware.

    Performances are boosted by at least 10x if not more, in general for all tasks/actions.
    Earlier the rebuild of NodeBB took about 5+ minutes, now it is done within ~50 seconds frame.
    GitLab reconfigure took 8+ minutes earlier, now it is ~10-15 seconds.
    Backup procedures took 10-15 + minutes. Now is under 1 minute.

    Next major step for upgrade would be quality USB 3.0 to Ethernet adapter.

    yea

    posted in Announcements
  • RE: Script to check MAC addresses (connected/disconnected) and internet connectivity [via e-mail]

    Also please bare in mind that some devices do have hibernation when they are not actively used. For example during testing, my iPhone was appearing and disappearing even though the WiFi was enabled - background fetching rendered it visible for short period of time and it was mostly preserving battery. I do not doubt that many/all mobile devices do it so you will have lots of noise in logs.

    posted in #! Request Script #!