# Jump Start: 4553v1 NB-IoT Dev Board :::warning [v1 Datasheet](https://www.m2mgermany.de/shop/media/webshop_dl/AcSiP/4470_TD2115M_DataSheet_V0.3_20180925.pdf ) [v2 Datasheet](https://www.quectel.com/wp-content/uploads/2021/03/Quectel_BC20_硬件设计手册_V1.0.pdf) AT Commands: https://drive.google.com/file/d/1_7T8yJUBVWVXtiO25tX-RsHotYatrYCC/view Edu Platform: https://drive.google.com/file/d/1Lx2RdiiX-Yj7bRdBKsf9aHPhf_hYKUBq/view NBIOT/GW/3bf90242ac110003 0 => Fan 1 => LED ::: ## 1. Install NRF Connect Programmer ## 2. Connect the JLink, Install Driver ![image](https://hackmd.io/_uploads/HkNP66c1A.png) Download the corresponding driver from Segger, for our Lab Version is **7.88j**. https://www.segger.com/downloads/jlink/JLink_Windows_V788j_x86_64.exe Check with the nRF Connect ![image](https://hackmd.io/_uploads/HJcNgCqk0.png) ![image](https://hackmd.io/_uploads/rkOGedL7R.png) ![image](https://hackmd.io/_uploads/Hk3rgOU7R.png) bottom left to top: v33rf swdio swdclk gnd ## 3. Check Flash ![image](https://hackmd.io/_uploads/BJ2DlAq10.png) ## 4. Set Arduino Additional Board JSON (Go to preferences): https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json ![image](https://hackmd.io/_uploads/BJHeYRcJR.png) * Board: Generic nRF52 * SoftDevice: S132 * Programmer: J-link * Low Frequency Clock: Crystal Oscillator ![image](https://hackmd.io/_uploads/S1Dpb1jkA.png) Don't forget to choose softdevice Install Library: BLEPeripheral Sandeep :::danger To debug serial need to put sim card ::: ## 5. Wiring (v1) PO_16 connect to CH_RX to debug J1 is NB Antenna ![image](https://hackmd.io/_uploads/ByhJuPLQA.png) ![image](https://hackmd.io/_uploads/Hksz_PUQA.png) ![image](https://hackmd.io/_uploads/r1vrdDIQ0.png) # I2C :::info Variants :arrow_forward: Generic :arrow_forward: Digital Map Debug: https://www.gammon.com.au/i2c ::: ![image](https://hackmd.io/_uploads/S1_O_B-zC.png) Variant.h ![image](https://hackmd.io/_uploads/rJop_rWMC.png) ## Power ```cpp= // // FILE: INA219_test_I2C.ino // AUTHOR: Rob Tillaart // PURPOSE: test I2C speed. // URL: https://github.com/RobTillaart/INA219 #include "INA219.h" #include <SoftwareSerial.h> #include "Wire.h" #define ledPin 17 SoftwareSerial debugSerial(15, 16); INA219 INA(0x40); void setup() { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // debug serial: 傳debug訊息給電腦看 debugSerial.listen(); debugSerial.begin(115200); // For debug message delay(2000); while(!debugSerial); debugSerial.println("\n\rSystem Start"); digitalWrite(ledPin, HIGH); debugSerial.println(__FILE__); debugSerial.print("INA219_LIB_VERSION: "); debugSerial.println(INA219_LIB_VERSION); Wire.begin(); for (byte x = 2; x <= 7; x++) { Wire.beginTransmission (64); Wire.write (x); if (Wire.endTransmission () == 0){ digitalWrite (ledPin, HIGH); debugSerial.println("Success"); } else { digitalWrite (ledPin, LOW); debugSerial.println("Failed"); } delay (200); } debugSerial.print("Address: "); debugSerial.println(INA.getAddress()); for (uint32_t speed = 50000; speed <= 800000; speed += 50000) { delay(100); Wire.setClock(speed); uint32_t start = micros(); uint8_t mode = INA.getMode(); uint32_t stop = micros(); debugSerial.print(speed); debugSerial.print("\t"); debugSerial.print(stop - start); debugSerial.print("\t"); debugSerial.println(mode); } debugSerial.println("\n...done..."); // INA.setMaxCurrentShunt(1, 0.002); // delay(1000); // INA.setMaxCurrentShunt(2.5, 0.002); // delay(1000); INA.setMaxCurrentShunt(5, 0.002); delay(1000); // INA.setMaxCurrentShunt(7.5, 0.002); // delay(1000); // INA.setMaxCurrentShunt(10, 0.002); // delay(1000); // INA.setMaxCurrentShunt(15, 0.002); // delay(1000); // INA.setMaxCurrentShunt(20, 0.002); // delay(10000); debugSerial.println(INA.getBusVoltageRange()); } void loop() { debugSerial.println("\n\tBUS\t\tSHUNT\t\tCURRENT\t\tPOWER\t\tOVF\t\tCNVR"); for (int i = 0; i < 20; i++) { debugSerial.print("\t"); debugSerial.print(INA.getBusVoltage(), 2); debugSerial.print("\t\t"); debugSerial.print(INA.getShuntVoltage_mV(), 2); debugSerial.print("\t\t"); debugSerial.print(INA.getCurrent_mA(), 2); debugSerial.print("\t\t"); debugSerial.print(INA.getPower_mW(), 2); debugSerial.print("\t\t"); debugSerial.print(INA.getMathOverflowFlag()); debugSerial.print("\t\t"); debugSerial.print(INA.getConversionFlag()); debugSerial.println(); delay(1000); } delay(1000); } // -- END OF FILE -- ``` Low Power: ![image](https://hackmd.io/_uploads/SkruODUXA.png) Normal Power: ![image](https://hackmd.io/_uploads/BkwzcwIXR.png) Dead: ![image](https://hackmd.io/_uploads/BJ5BqDLmC.png) **Integration Success: ** ![image](https://hackmd.io/_uploads/HktcWdUQR.png) ![image](https://hackmd.io/_uploads/SJedXu87R.png) **5/23** ![image](https://hackmd.io/_uploads/Sy5Oqo37C.png) NTHU EDU UDP: 教育版本的udp server也啟動了 位置在 140.114.71.154:5353 PRODUCTION SUCCESS UPLOAD ![image](https://hackmd.io/_uploads/BkZr4n3QR.png) ![image](https://hackmd.io/_uploads/SJ2hm327R.png) why got control? ![image](https://hackmd.io/_uploads/HyoAXn37A.png) 5/26 LOG ``` 19:30:58.082 -> OVF : 0 CNVR : 1 19:30:59.099 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d00930014021410000002A2000f 19:31:00.677 -> 19:31:00.677 -> 1,21 19:31:00.677 -> 19:31:00.677 -> OK 19:31:00.677 -> 19:31:00.677 -> Fan state: 0 Fan timer: 0 19:31:00.714 -> current millis: 280620 fan end millis: 0 19:31:00.714 -> LED state: 0 LED timer: 0 19:31:00.714 -> current millis: 280627 led end millis: 0 19:31:00.714 -> Motor state: 0 Motor timer: 0 19:31:00.714 -> current millis: 280634 led end millis: 0 19:31:00.714 -> Light val = 276, res = 17659.29 19:31:00.714 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d009400140214100000026544fb 19:31:02.338 -> 19:31:02.338 -> 1,21 19:31:02.338 -> 19:31:02.338 -> OK 19:31:02.338 -> 19:31:02.338 -> Soil humidity val = 568 19:31:02.338 -> , res = 6057.05 19:31:02.338 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d009500140214100000027817a9 19:31:45.602 -> OVF : 0 CNVR : 1 19:31:46.610 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d00af0014021410000002A2000f 19:31:48.213 -> 19:31:48.213 -> 1,21 19:31:48.213 -> 19:31:48.213 -> OK 19:31:48.213 -> 19:31:48.213 -> Fan state: 0 Fan timer: 0 19:31:48.213 -> current millis: 328131 fan end millis: 0 19:31:48.213 -> LED state: 0 LED timer: 0 19:31:48.213 -> current millis: 328138 led end millis: 0 19:31:48.213 -> Motor state: 0 Motor timer: 0 19:31:48.213 -> current millis: 328145 led end millis: 0 19:31:48.213 -> Light val = 271, res = 17339.38 19:31:48.213 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d00b000140214100000026543bb 19:31:49.813 -> 19:31:49.813 -> 1,21 19:31:49.813 -> 19:31:49.813 -> OK 19:31:49.813 -> 19:31:49.813 -> Soil humidity val = 558 19:31:49.848 -> , res = 5950.41 19:31:49.848 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d00b1001402141000000278173e 19:31:51.451 -> 19:31:51.451 -> 1,21 19:31:51.451 -> 19:31:51.451 -> OK 19:31:51.451 -> 19:31:51.451 -> DHT => Time out error 19:31:51.451 -> BUS (V) : 0.98 19:31:51.451 -> SHUNT (mV) : 14.38 19:31:51.451 -> CURRENT (mA) : 160.06 19:31:51.451 -> POWER (mW) : 158.69 19:31:51.451 -> OVF : 0 CNVR : 1 19:31:52.455 -> AT+NSOST=1,140.114.71.154,5353,21,ffff3300ffe8274d00b30014021410000002A2000f ``` ![image](https://hackmd.io/_uploads/SkxW8ixIA.png) ![image](https://hackmd.io/_uploads/HJI9Lse8C.png) ![image](https://hackmd.io/_uploads/SypQwoeUC.png) NB Error ![image](https://hackmd.io/_uploads/HJdfZjbI0.png) ![image](https://hackmd.io/_uploads/B1x_Zsb8C.png) ![image](https://hackmd.io/_uploads/rJIgBMXUC.png) ![image](https://hackmd.io/_uploads/H197BM78A.png) ![image](https://hackmd.io/_uploads/ByyvSGQ8C.png) **I2C Check** ![image](https://hackmd.io/_uploads/Hkgo7ylvA.png) ![image](https://hackmd.io/_uploads/Bkb48ygvA.png) ACK ```python= def on_message(client, userdata, message): print(message.topic) msg_string = str(message.payload.decode("utf-8")) msg_json = json.loads(msg_string)[0] print(msg_json) data = msg_json['data'].lower() header = data[:2] body = data[2:] macAddr = msg_json['macAddr'] if header == '1f': pin = body[:2] value = int(body[2:], base=16) print(pin, value) client.publish("PBL/UL/pbl-test", json.dumps([{ 'macAddr': macAddr, 'data': '00' + data }])) client.publish("PBL/UL/pbl-test", json.dumps([{ 'macAddr': macAddr, 'data': '002f' + pin + ('01' if value > 0 else '00') }])) ``` Software I2C Porting ![image](https://hackmd.io/_uploads/HkdloCzd0.png) ![image](https://hackmd.io/_uploads/rJYyoRfOA.png) ACK ![image](https://hackmd.io/_uploads/rJoJxlNOR.png) ![image](https://hackmd.io/_uploads/r1GxelV_0.png) ![image](https://hackmd.io/_uploads/SJ3VxeN_0.png) https://pastebin.com/aqgSQmCS