Software

How to Migrate an Oracle Linux VM from VMware vSphere to OCI

1) Clone the VM.

2) Optionally, edit the /etc/sysconfig/network-scripts/ifcfg-sampleif file:

DEVICE=sampleif
BOOTPROTO=dhcp
TYPE=Ethernet

If using OL 6, also remove the /etc/udev/rules.d/70-persistent-net.rules file.

3) Comment out block volumes in the /etc/fstab file.

4) Convert the boot volume to a VMDK image.

5) If needed for making additional changes, import the VMDK image into VirtualBox. Make sure to merge changes into the VMDK image when using the stream-optimized format. Also, redo steps 2-3.

6) Upload the VMDK image to a bucket and import it into OCI.

7) Create an instance with the new image.

8) Create, attach, and sync block volumes.

You can find more details here.

Hardware, Software

How to Connect to a Network with Grove UART Wi-Fi in NodeMCU

1) Connect the module to the D5 port.

2) Install the SimpleTimer library.

3) Run the following code:

#include <SimpleTimer.h>
#include <SoftwareSerial.h>

const int RX_PIN = 0, TX_PIN = 14;

SoftwareSerial SoftSerial(RX_PIN, TX_PIN);

SimpleTimer timer; // avoid the delay issue (http://playground.arduino.cc/Code/AvoidDelay)

void setup() {
  SoftSerial.begin(115200);

  Serial.begin(9600);

  SoftSerial.println("ATE0"); // disable echo

  timer.setTimeout(5000, [] {

    if (SoftSerial.find("OK")) {
      SoftSerial.println("AT+CWJAP_CUR=\"SampleNetwork\",\"SamplePassword\""); // connect to AP

      timer.setTimeout(5000, [] {

        if (SoftSerial.find("OK")) {
          Serial.println("Connected!");
        }

      });
    }

  });
}

void loop() {
  timer.run();
}
Hardware, Software

How to Measure Distance with a Grove Ultrasonic Ranger in NodeMCU

1) Connect the module to the D5 port.

2) Install the module library.

3) Run the following code:

#include <Ultrasonic.h>

const int PIN = 14;

Ultrasonic ultrasonic(PIN);

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(ultrasonic.MeasureInCentimeters()); // or MeasureInInches()

  delay(1000);
}
Hardware, Software

How to Get Temperature from a Grove Temperature Sensor in NodeMCU

1) Connect the module to the A0 port.

2) Run the following code:

#include <math.h>

const int B = 4275; // for v1.1 module

void setup() {
  Serial.begin(9600);
}

void loop() {
  int v = analogRead(0);

  float r = (float)(1023 - v) * 10000 / v;
  float t = 1 / (log(r / 10000) / B + 1 / 298.15) - 273.15;

  Serial.println(t);

  delay(1000);
}
Hardware, Software

How to Send/Receive with a Grove 433 Mhz Simple RF Kit in NodeMCU

Emitter

1) Connect the module to the D3 port.

2) Install the RadioHead library.

3) Run the following code:

#include <RH_ASK.h>
 
const int BIT_RATE = 2000;
 
const int RX_PIN = 14, TX_PIN = 0;
 
RH_ASK driver(BIT_RATE, RX_PIN, TX_PIN);
 
void setup() {
  driver.init();
}
 
void loop() {
  char str[] = "Simples Assim";
 
  driver.send((uint8_t *) str, strlen(str));
 
  driver.waitPacketSent();
 
  delay(1000);
}

Receiver

1) Connect the module to the D3 port.

2) Install the RadioHead library.

3) Run the following language:

#include <RH_ASK.h>

const int BIT_RATE = 2000;

const int RX_PIN = 0;

RH_ASK driver(BIT_RATE, RX_PIN);

void setup() {
  Serial.begin(9600);

  driver.init();
}

void loop() {
  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];

  uint8_t buflen = sizeof(buf);

  if (driver.recv(buf, &buflen)) {

    for (int i = 0; i < buflen; i++)
      Serial.print((char) buf[i]);

    Serial.println("");
  }

}